{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime\n",
    "import gc\n",
    "import glob\n",
    "import os\n",
    "import time\n",
    "import xml.etree.ElementTree as ET\n",
    "\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "from loguru import logger\n",
    "from tqdm import tqdm"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Функции обработки файлов"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "def cleanup(x):\n",
    "    \"\"\"\n",
    "    Ручная очистка объекта\n",
    "    \"\"\"\n",
    "    del x\n",
    "    gc.collect()\n",
    "\n",
    "\n",
    "def parse_xml(x):\n",
    "    \"\"\"\n",
    "    Парсинг XML-файла в датафрейм Pandas\n",
    "    \"\"\"\n",
    "    tree = ET.parse(x)\n",
    "    root = tree.getroot()\n",
    "    df = [child.attrib for child in root]\n",
    "    df = pd.DataFrame.from_dict(df)\n",
    "    return df\n",
    "\n",
    "\n",
    "def get_adms(df):\n",
    "    \"\"\"\n",
    "    Получаем административное деление \"объект-родитель\" в словаре для последующего использования\n",
    "    \"\"\"\n",
    "    rftree = df[['OBJECTID', 'PARENTOBJID']].groupby(\n",
    "        by='OBJECTID'\n",
    "    )['PARENTOBJID'].apply(list).to_dict()\n",
    "    return rftree\n",
    "\n",
    "\n",
    "def get_adms_rec_rev(chain, rdadm, housdict, objdict):\n",
    "    \"\"\"\n",
    "    Строим рекурсивную цепочку адресов\n",
    "    \"\"\"\n",
    "    objid = chain[-1]\n",
    "\n",
    "    if objid in rdadm and objid == objid:\n",
    "        prnts = rdadm[objid]\n",
    "        if len(prnts) > 1:\n",
    "            prnts = [x for x in prnts if x in objdict]\n",
    "            if len(prnts) > 1:\n",
    "                seedOKTMO = housdict[chain[0]]['OKTMO']\n",
    "                prntOKTMO = {prnt: objdict[prnt]['OKTMO'] for prnt in prnts}\n",
    "                prnts = [prnt for prnt in prnts if len(set(seedOKTMO).intersection(set(prntOKTMO[prnt]))) > 0]\n",
    "            if len(prnts) == 0:\n",
    "                return None\n",
    "        chains = [chain + [obj] for obj in prnts if obj == obj]\n",
    "        if len(chains) > 1:\n",
    "            return [get_adms_rec_rev(ch, rdadm, housdict, objdict) for ch in chains]\n",
    "        if len(chains) == 0:\n",
    "            return chain\n",
    "        return get_adms_rec_rev(chains[0], rdadm, housdict, objdict)\n",
    "    else:\n",
    "        return chain\n",
    "\n",
    "    \n",
    "def reduce_included(x):\n",
    "    \"\"\"\n",
    "    Сокращение цепочки\n",
    "    \"\"\"\n",
    "    maxl = 0\n",
    "    maxch = []\n",
    "    x = [tuple(y) for y in x]\n",
    "    for y in x:\n",
    "        maxl = (len(y) > maxl) * len(y) + (len(y) <= maxl) * maxl\n",
    "        maxch = y if len(y) == maxl else maxch\n",
    "    mask = [len(set(y).intersection(set(maxch))) == len(y) and y != maxch for y in x]\n",
    "    ret = [y for y, z in zip(x, mask) if not z]\n",
    "    single = False\n",
    "    if len(ret) == 1:\n",
    "        ret = ret[0]\n",
    "        single = True\n",
    "    return ret, single\n",
    "\n",
    "\n",
    "def get_town(x):\n",
    "    \"\"\"\n",
    "    Очистка цепочки, получение адресов\n",
    "    \"\"\"\n",
    "    priority = ['5', '6', '4', '7', '1']\n",
    "    street = [f'{i}' for i in range(8, 0, -1)]\n",
    "    streets = [p for p in street if x[p] == 1]\n",
    "    if len(streets) == 0:\n",
    "        street = None\n",
    "    else:\n",
    "        street = streets[0]\n",
    "    town = [p for p in priority if p != street and x[p] == 1]\n",
    "    town = town[0] if len(town) > 0 else None\n",
    "    leftover = [\n",
    "        x for x in streets\n",
    "        if x != street\n",
    "        and x != town\n",
    "        and x not in ['1', '2', '3']\n",
    "    ]\n",
    "    muni = [x for x in streets if x in ['2', '3']]\n",
    "\n",
    "    return street, town, leftover, muni"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Загрузка регионов"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'C:/Users/GlazkovOI/minzdrav/data/gar\\\\29'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# regions = glob.glob('data/[0-9][0-9]')\n",
    "regions = glob.glob('C:/Users/GlazkovOI/minzdrav/data/gar/[0-9][0-9]')\n",
    "region = regions[0]\n",
    "region"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Фильтруем исторические данные по атрибутам `ISACTUAL` и `ISACTIVE` оставляем только активные и актуальные."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>OBJECTID</th>\n",
       "      <th>OBJECTGUID</th>\n",
       "      <th>CHANGEID</th>\n",
       "      <th>NAME</th>\n",
       "      <th>TYPENAME</th>\n",
       "      <th>LEVEL</th>\n",
       "      <th>OPERTYPEID</th>\n",
       "      <th>PREVID</th>\n",
       "      <th>NEXTID</th>\n",
       "      <th>UPDATEDATE</th>\n",
       "      <th>STARTDATE</th>\n",
       "      <th>ENDDATE</th>\n",
       "      <th>ISACTUAL</th>\n",
       "      <th>ISACTIVE</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>541325</td>\n",
       "      <td>445407</td>\n",
       "      <td>425d519f-3636-41bd-ae7e-0c284911ada9</td>\n",
       "      <td>1115994</td>\n",
       "      <td>Лисьи Борки</td>\n",
       "      <td>тер. СНТ</td>\n",
       "      <td>7</td>\n",
       "      <td>20</td>\n",
       "      <td>541320</td>\n",
       "      <td>0</td>\n",
       "      <td>2019-10-11</td>\n",
       "      <td>2019-10-07</td>\n",
       "      <td>2079-06-06</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1810975</td>\n",
       "      <td>95239078</td>\n",
       "      <td>6621d717-388a-4533-9571-142c34a22acc</td>\n",
       "      <td>138195595</td>\n",
       "      <td>Тарасовское</td>\n",
       "      <td>с.п.</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2079-06-06</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1810988</td>\n",
       "      <td>95239091</td>\n",
       "      <td>42b314b1-95a4-406d-89bd-d81fc316f69c</td>\n",
       "      <td>138195608</td>\n",
       "      <td>Верхнетоемское</td>\n",
       "      <td>с.п.</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2079-06-06</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1811016</td>\n",
       "      <td>95239119</td>\n",
       "      <td>9e0cb420-4511-48a0-bac1-966f6170bfc7</td>\n",
       "      <td>138195636</td>\n",
       "      <td>Подюжское</td>\n",
       "      <td>с.п.</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2079-06-06</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>1811083</td>\n",
       "      <td>95239186</td>\n",
       "      <td>413ad5f9-fb3d-431e-8619-0376df3e9f4b</td>\n",
       "      <td>138195703</td>\n",
       "      <td>Северодвинск</td>\n",
       "      <td>г.о.</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2079-06-06</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        ID  OBJECTID                            OBJECTGUID   CHANGEID  \\\n",
       "0   541325    445407  425d519f-3636-41bd-ae7e-0c284911ada9    1115994   \n",
       "4  1810975  95239078  6621d717-388a-4533-9571-142c34a22acc  138195595   \n",
       "5  1810988  95239091  42b314b1-95a4-406d-89bd-d81fc316f69c  138195608   \n",
       "6  1811016  95239119  9e0cb420-4511-48a0-bac1-966f6170bfc7  138195636   \n",
       "7  1811083  95239186  413ad5f9-fb3d-431e-8619-0376df3e9f4b  138195703   \n",
       "\n",
       "             NAME  TYPENAME LEVEL OPERTYPEID  PREVID NEXTID  UPDATEDATE  \\\n",
       "0     Лисьи Борки  тер. СНТ     7         20  541320      0  2019-10-11   \n",
       "4     Тарасовское      с.п.     4          0       0      0  2011-01-01   \n",
       "5  Верхнетоемское      с.п.     4          0       0      0  2011-01-01   \n",
       "6       Подюжское      с.п.     4          0       0      0  2011-01-01   \n",
       "7    Северодвинск      г.о.     3          0       0      0  2011-01-01   \n",
       "\n",
       "    STARTDATE     ENDDATE ISACTUAL ISACTIVE  \n",
       "0  2019-10-07  2079-06-06        1        1  \n",
       "4  2011-01-01  2079-06-06        1        1  \n",
       "5  2011-01-01  2079-06-06        1        1  \n",
       "6  2011-01-01  2079-06-06        1        1  \n",
       "7  2011-01-01  2079-06-06        1        1  "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fname = glob.glob(os.path.join(region, 'AS_ADDR_OBJ_*.XML')) # первый файл\n",
    "fname = [x for x in fname if 'PARAMS' not in x and 'DIVISION' not in x]\n",
    "if len(fname) != 1:\n",
    "    msg = f'Проверить количество файлов региона {region} там {len(fname)} файлов'\n",
    "    logger.error(msg)\n",
    "    raise Exception(msg)\n",
    "fname = fname[0]\n",
    "adobj = parse_xml(fname)\n",
    "adobj = adobj[(adobj['ISACTUAL'] == '1') & (adobj['ISACTIVE'] == '1')]\n",
    "adobj.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Извлечение административно-территориального деления и его уровней"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>LEVEL</th>\n",
       "      <th>NAME</th>\n",
       "      <th>SHORTNAME</th>\n",
       "      <th>DESC</th>\n",
       "      <th>UPDATEDATE</th>\n",
       "      <th>STARTDATE</th>\n",
       "      <th>ENDDATE</th>\n",
       "      <th>ISACTIVE</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>Автономная область</td>\n",
       "      <td>Аобл</td>\n",
       "      <td>Автономная область</td>\n",
       "      <td>1900-01-01</td>\n",
       "      <td>1900-01-01</td>\n",
       "      <td>2015-11-05</td>\n",
       "      <td>true</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>Автономная область</td>\n",
       "      <td>а.обл.</td>\n",
       "      <td>Автономная область</td>\n",
       "      <td>2015-11-05</td>\n",
       "      <td>2015-11-05</td>\n",
       "      <td>2079-06-06</td>\n",
       "      <td>true</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>Автономный округ</td>\n",
       "      <td>а.окр.</td>\n",
       "      <td>Автономный округ</td>\n",
       "      <td>2015-11-05</td>\n",
       "      <td>2015-11-05</td>\n",
       "      <td>2079-06-06</td>\n",
       "      <td>true</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>Автономный округ</td>\n",
       "      <td>АО</td>\n",
       "      <td>Автономный округ</td>\n",
       "      <td>1900-01-01</td>\n",
       "      <td>1900-01-01</td>\n",
       "      <td>2015-11-05</td>\n",
       "      <td>true</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>Город</td>\n",
       "      <td>г</td>\n",
       "      <td>Город</td>\n",
       "      <td>1900-01-01</td>\n",
       "      <td>1900-01-01</td>\n",
       "      <td>2015-11-05</td>\n",
       "      <td>true</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  ID LEVEL                NAME SHORTNAME                DESC  UPDATEDATE  \\\n",
       "0  5     1  Автономная область      Аобл  Автономная область  1900-01-01   \n",
       "1  2     1  Автономная область    а.обл.  Автономная область  2015-11-05   \n",
       "2  3     1    Автономный округ    а.окр.    Автономный округ  2015-11-05   \n",
       "3  4     1    Автономный округ        АО    Автономный округ  1900-01-01   \n",
       "4  6     1               Город         г               Город  1900-01-01   \n",
       "\n",
       "    STARTDATE     ENDDATE ISACTIVE  \n",
       "0  1900-01-01  2015-11-05     true  \n",
       "1  2015-11-05  2079-06-06     true  \n",
       "2  2015-11-05  2079-06-06     true  \n",
       "3  1900-01-01  2015-11-05     true  \n",
       "4  1900-01-01  2015-11-05     true  "
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fname = glob.glob('C:/Users/GlazkovOI/minzdrav/data/gar/AS_ADDR_OBJ_TYPES_*.XML')\n",
    "if len(fname) != 1:\n",
    "    msg = f'Проверить количество файлов региона {region} там {len(fname)} файлов'\n",
    "    logger.error(msg)\n",
    "    raise Exception(msg)\n",
    "fname = fname[0]\n",
    "adobjt = parse_xml(fname)\n",
    "adobjt.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>OBJECTID</th>\n",
       "      <th>OBJECTGUID</th>\n",
       "      <th>CHANGEID</th>\n",
       "      <th>NAME</th>\n",
       "      <th>TYPENAME</th>\n",
       "      <th>LEVEL</th>\n",
       "      <th>OPERTYPEID</th>\n",
       "      <th>PREVID</th>\n",
       "      <th>NEXTID</th>\n",
       "      <th>UPDATEDATE</th>\n",
       "      <th>STARTDATE</th>\n",
       "      <th>ENDDATE</th>\n",
       "      <th>ISACTUAL</th>\n",
       "      <th>ISACTIVE</th>\n",
       "      <th>TYPELONGNAME</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>541325</td>\n",
       "      <td>445407</td>\n",
       "      <td>425d519f-3636-41bd-ae7e-0c284911ada9</td>\n",
       "      <td>1115994</td>\n",
       "      <td>Лисьи Борки</td>\n",
       "      <td>тер. СНТ</td>\n",
       "      <td>7</td>\n",
       "      <td>20</td>\n",
       "      <td>541320</td>\n",
       "      <td>0</td>\n",
       "      <td>2019-10-11</td>\n",
       "      <td>2019-10-07</td>\n",
       "      <td>2079-06-06</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>Территория садоводческого некоммерческого това...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1810975</td>\n",
       "      <td>95239078</td>\n",
       "      <td>6621d717-388a-4533-9571-142c34a22acc</td>\n",
       "      <td>138195595</td>\n",
       "      <td>Тарасовское</td>\n",
       "      <td>с.п.</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2079-06-06</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>сельское поселение</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1810988</td>\n",
       "      <td>95239091</td>\n",
       "      <td>42b314b1-95a4-406d-89bd-d81fc316f69c</td>\n",
       "      <td>138195608</td>\n",
       "      <td>Верхнетоемское</td>\n",
       "      <td>с.п.</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2079-06-06</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>сельское поселение</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1811016</td>\n",
       "      <td>95239119</td>\n",
       "      <td>9e0cb420-4511-48a0-bac1-966f6170bfc7</td>\n",
       "      <td>138195636</td>\n",
       "      <td>Подюжское</td>\n",
       "      <td>с.п.</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2079-06-06</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>сельское поселение</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1811083</td>\n",
       "      <td>95239186</td>\n",
       "      <td>413ad5f9-fb3d-431e-8619-0376df3e9f4b</td>\n",
       "      <td>138195703</td>\n",
       "      <td>Северодвинск</td>\n",
       "      <td>г.о.</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2079-06-06</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>Городской округ</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        ID  OBJECTID                            OBJECTGUID   CHANGEID  \\\n",
       "0   541325    445407  425d519f-3636-41bd-ae7e-0c284911ada9    1115994   \n",
       "1  1810975  95239078  6621d717-388a-4533-9571-142c34a22acc  138195595   \n",
       "2  1810988  95239091  42b314b1-95a4-406d-89bd-d81fc316f69c  138195608   \n",
       "3  1811016  95239119  9e0cb420-4511-48a0-bac1-966f6170bfc7  138195636   \n",
       "4  1811083  95239186  413ad5f9-fb3d-431e-8619-0376df3e9f4b  138195703   \n",
       "\n",
       "             NAME  TYPENAME LEVEL OPERTYPEID  PREVID NEXTID  UPDATEDATE  \\\n",
       "0     Лисьи Борки  тер. СНТ     7         20  541320      0  2019-10-11   \n",
       "1     Тарасовское      с.п.     4          0       0      0  2011-01-01   \n",
       "2  Верхнетоемское      с.п.     4          0       0      0  2011-01-01   \n",
       "3       Подюжское      с.п.     4          0       0      0  2011-01-01   \n",
       "4    Северодвинск      г.о.     3          0       0      0  2011-01-01   \n",
       "\n",
       "    STARTDATE     ENDDATE ISACTUAL ISACTIVE  \\\n",
       "0  2019-10-07  2079-06-06        1        1   \n",
       "1  2011-01-01  2079-06-06        1        1   \n",
       "2  2011-01-01  2079-06-06        1        1   \n",
       "3  2011-01-01  2079-06-06        1        1   \n",
       "4  2011-01-01  2079-06-06        1        1   \n",
       "\n",
       "                                        TYPELONGNAME  \n",
       "0  Территория садоводческого некоммерческого това...  \n",
       "1                                 сельское поселение  \n",
       "2                                 сельское поселение  \n",
       "3                                 сельское поселение  \n",
       "4                                    Городской округ  "
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "adobj = adobj.merge(\n",
    "    adobjt[['SHORTNAME', 'DESC', 'LEVEL']].rename(\n",
    "        columns={\n",
    "            'SHORTNAME': 'TYPENAME',\n",
    "            'DESC': 'TYPELONGNAME'\n",
    "        }\n",
    "    ),\n",
    "    on=['LEVEL', 'TYPENAME']\n",
    ")\n",
    "cleanup(adobjt)\n",
    "adobj.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>OBJECTID</th>\n",
       "      <th>OBJECTGUID</th>\n",
       "      <th>CHANGEID</th>\n",
       "      <th>NAME</th>\n",
       "      <th>TYPENAME</th>\n",
       "      <th>LEVEL</th>\n",
       "      <th>OPERTYPEID</th>\n",
       "      <th>PREVID</th>\n",
       "      <th>NEXTID</th>\n",
       "      <th>UPDATEDATE</th>\n",
       "      <th>STARTDATE</th>\n",
       "      <th>ENDDATE</th>\n",
       "      <th>ISACTUAL</th>\n",
       "      <th>ISACTIVE</th>\n",
       "      <th>TYPELONGNAME</th>\n",
       "      <th>LEVELNAME</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>541325</td>\n",
       "      <td>445407</td>\n",
       "      <td>425d519f-3636-41bd-ae7e-0c284911ada9</td>\n",
       "      <td>1115994</td>\n",
       "      <td>Лисьи Борки</td>\n",
       "      <td>тер. СНТ</td>\n",
       "      <td>7</td>\n",
       "      <td>20</td>\n",
       "      <td>541320</td>\n",
       "      <td>0</td>\n",
       "      <td>2019-10-11</td>\n",
       "      <td>2019-10-07</td>\n",
       "      <td>2079-06-06</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>Территория садоводческого некоммерческого това...</td>\n",
       "      <td>Элемент планировочной структуры</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1810975</td>\n",
       "      <td>95239078</td>\n",
       "      <td>6621d717-388a-4533-9571-142c34a22acc</td>\n",
       "      <td>138195595</td>\n",
       "      <td>Тарасовское</td>\n",
       "      <td>с.п.</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2079-06-06</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>сельское поселение</td>\n",
       "      <td>Сельское/городское поселение</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1810988</td>\n",
       "      <td>95239091</td>\n",
       "      <td>42b314b1-95a4-406d-89bd-d81fc316f69c</td>\n",
       "      <td>138195608</td>\n",
       "      <td>Верхнетоемское</td>\n",
       "      <td>с.п.</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2079-06-06</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>сельское поселение</td>\n",
       "      <td>Сельское/городское поселение</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1811016</td>\n",
       "      <td>95239119</td>\n",
       "      <td>9e0cb420-4511-48a0-bac1-966f6170bfc7</td>\n",
       "      <td>138195636</td>\n",
       "      <td>Подюжское</td>\n",
       "      <td>с.п.</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2079-06-06</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>сельское поселение</td>\n",
       "      <td>Сельское/городское поселение</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1811083</td>\n",
       "      <td>95239186</td>\n",
       "      <td>413ad5f9-fb3d-431e-8619-0376df3e9f4b</td>\n",
       "      <td>138195703</td>\n",
       "      <td>Северодвинск</td>\n",
       "      <td>г.о.</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>2079-06-06</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>Городской округ</td>\n",
       "      <td>Муниципальный район</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        ID  OBJECTID                            OBJECTGUID   CHANGEID  \\\n",
       "0   541325    445407  425d519f-3636-41bd-ae7e-0c284911ada9    1115994   \n",
       "1  1810975  95239078  6621d717-388a-4533-9571-142c34a22acc  138195595   \n",
       "2  1810988  95239091  42b314b1-95a4-406d-89bd-d81fc316f69c  138195608   \n",
       "3  1811016  95239119  9e0cb420-4511-48a0-bac1-966f6170bfc7  138195636   \n",
       "4  1811083  95239186  413ad5f9-fb3d-431e-8619-0376df3e9f4b  138195703   \n",
       "\n",
       "             NAME  TYPENAME LEVEL OPERTYPEID  PREVID NEXTID  UPDATEDATE  \\\n",
       "0     Лисьи Борки  тер. СНТ     7         20  541320      0  2019-10-11   \n",
       "1     Тарасовское      с.п.     4          0       0      0  2011-01-01   \n",
       "2  Верхнетоемское      с.п.     4          0       0      0  2011-01-01   \n",
       "3       Подюжское      с.п.     4          0       0      0  2011-01-01   \n",
       "4    Северодвинск      г.о.     3          0       0      0  2011-01-01   \n",
       "\n",
       "    STARTDATE     ENDDATE ISACTUAL ISACTIVE  \\\n",
       "0  2019-10-07  2079-06-06        1        1   \n",
       "1  2011-01-01  2079-06-06        1        1   \n",
       "2  2011-01-01  2079-06-06        1        1   \n",
       "3  2011-01-01  2079-06-06        1        1   \n",
       "4  2011-01-01  2079-06-06        1        1   \n",
       "\n",
       "                                        TYPELONGNAME  \\\n",
       "0  Территория садоводческого некоммерческого това...   \n",
       "1                                 сельское поселение   \n",
       "2                                 сельское поселение   \n",
       "3                                 сельское поселение   \n",
       "4                                    Городской округ   \n",
       "\n",
       "                         LEVELNAME  \n",
       "0  Элемент планировочной структуры  \n",
       "1     Сельское/городское поселение  \n",
       "2     Сельское/городское поселение  \n",
       "3     Сельское/городское поселение  \n",
       "4              Муниципальный район  "
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fname = glob.glob('C:/Users/GlazkovOI/minzdrav/data/gar/AS_OBJECT_LEVELS_*.XML')\n",
    "if len(fname) != 1:\n",
    "    msg = f'Проверить количество файлов региона {region} там {len(fname)} файлов'\n",
    "    logger.error(msg)\n",
    "    raise Exception(msg)\n",
    "fname = fname[0]\n",
    "lev = parse_xml(fname)\n",
    "\n",
    "adobj = adobj.merge(\n",
    "    lev[['NAME', 'LEVEL']].rename(\n",
    "        columns={\n",
    "            'NAME': 'LEVELNAME'\n",
    "        }\n",
    "    ),\n",
    "    on='LEVEL'\n",
    ")\n",
    "adobj.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Извлекаем код ОКТМО"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>OBJECTID</th>\n",
       "      <th>CHANGEID</th>\n",
       "      <th>CHANGEIDEND</th>\n",
       "      <th>TYPEID</th>\n",
       "      <th>VALUE</th>\n",
       "      <th>UPDATEDATE</th>\n",
       "      <th>STARTDATE</th>\n",
       "      <th>ENDDATE</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>6642828</td>\n",
       "      <td>439145</td>\n",
       "      <td>1102824</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>2902</td>\n",
       "      <td>2018-07-12</td>\n",
       "      <td>1900-01-01</td>\n",
       "      <td>2079-06-06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>6642831</td>\n",
       "      <td>439145</td>\n",
       "      <td>1102824</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>2902</td>\n",
       "      <td>2018-07-12</td>\n",
       "      <td>1900-01-01</td>\n",
       "      <td>2079-06-06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>6642959</td>\n",
       "      <td>439145</td>\n",
       "      <td>1102824</td>\n",
       "      <td>0</td>\n",
       "      <td>15</td>\n",
       "      <td>0002</td>\n",
       "      <td>2018-07-12</td>\n",
       "      <td>1900-01-01</td>\n",
       "      <td>2079-06-06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>6642835</td>\n",
       "      <td>439145</td>\n",
       "      <td>1102824</td>\n",
       "      <td>1102843</td>\n",
       "      <td>7</td>\n",
       "      <td>11730000</td>\n",
       "      <td>2018-07-12</td>\n",
       "      <td>1900-01-01</td>\n",
       "      <td>2018-07-12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>6642903</td>\n",
       "      <td>439145</td>\n",
       "      <td>1102824</td>\n",
       "      <td>1102843</td>\n",
       "      <td>10</td>\n",
       "      <td>29000004005000201</td>\n",
       "      <td>2018-07-12</td>\n",
       "      <td>1900-01-01</td>\n",
       "      <td>2018-07-12</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        ID OBJECTID CHANGEID CHANGEIDEND TYPEID              VALUE  \\\n",
       "0  6642828   439145  1102824           0      3               2902   \n",
       "1  6642831   439145  1102824           0      4               2902   \n",
       "2  6642959   439145  1102824           0     15               0002   \n",
       "3  6642835   439145  1102824     1102843      7           11730000   \n",
       "4  6642903   439145  1102824     1102843     10  29000004005000201   \n",
       "\n",
       "   UPDATEDATE   STARTDATE     ENDDATE  \n",
       "0  2018-07-12  1900-01-01  2079-06-06  \n",
       "1  2018-07-12  1900-01-01  2079-06-06  \n",
       "2  2018-07-12  1900-01-01  2079-06-06  \n",
       "3  2018-07-12  1900-01-01  2018-07-12  \n",
       "4  2018-07-12  1900-01-01  2018-07-12  "
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fname = glob.glob(os.path.join(region, 'AS_ADDR_OBJ_PARAMS_*.XML'))\n",
    "fname = fname[0]\n",
    "adobjp = parse_xml(fname)\n",
    "adobjp.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'100028445': {'OKTMO': ['11730000136']},\n",
       " '100076751': {'OKTMO': ['11527000']},\n",
       " '100165939': {'OKTMO': ['11646432101']},\n",
       " '100166112': {'OKTMO': ['11646432101']},\n",
       " '100192284': {'OKTMO': ['11558000']},\n",
       " '100217692': {'OKTMO': ['11701000001']},\n",
       " '100244195': {'OKTMO': ['11701000001']},\n",
       " '100247812': {'OKTMO': ['11730000']},\n",
       " '100247813': {'OKTMO': ['11730000']},\n",
       " '100247814': {'OKTMO': ['11730000']},\n",
       " '100247815': {'OKTMO': ['11730000']},\n",
       " '100247816': {'OKTMO': ['11730000']},\n",
       " '100247817': {'OKTMO': ['11730000']},\n",
       " '100247818': {'OKTMO': ['11730000']},\n",
       " '100247819': {'OKTMO': ['11730000']},\n",
       " '100247820': {'OKTMO': ['11730000']},\n",
       " '100247821': {'OKTMO': ['11730000']},\n",
       " '100247822': {'OKTMO': ['11730000']},\n",
       " '100247823': {'OKTMO': ['11730000']},\n",
       " '100247824': {'OKTMO': ['11730000']},\n",
       " '100247825': {'OKTMO': ['11730000']},\n",
       " '100247826': {'OKTMO': ['11730000']},\n",
       " '100247827': {'OKTMO': ['11730000']},\n",
       " '100247828': {'OKTMO': ['11730000']},\n",
       " '100247869': {'OKTMO': ['11730000']},\n",
       " '100247870': {'OKTMO': ['11730000']},\n",
       " '100247871': {'OKTMO': ['11730000']},\n",
       " '100247872': {'OKTMO': ['11730000']},\n",
       " '100247873': {'OKTMO': ['11730000']},\n",
       " '100247874': {'OKTMO': ['11730000']},\n",
       " '100247875': {'OKTMO': ['11730000']},\n",
       " '100247876': {'OKTMO': ['11730000']},\n",
       " '100247877': {'OKTMO': ['11730000']},\n",
       " '100258689': {'OKTMO': ['11646101001']},\n",
       " '100258690': {'OKTMO': ['11646101001']},\n",
       " '100258691': {'OKTMO': ['11646101001']},\n",
       " '100265404': {'OKTMO': ['11527000448']},\n",
       " '100323063': {'OKTMO': ['11554000051']},\n",
       " '100379880': {'OKTMO': ['11527000']},\n",
       " '100395068': {'OKTMO': ['11730000']},\n",
       " '100408713': {'OKTMO': ['11558000001']},\n",
       " '100411584': {'OKTMO': ['11544000']},\n",
       " '100485478': {'OKTMO': ['11552000146']},\n",
       " '100485479': {'OKTMO': ['11552000146']},\n",
       " '100636446': {'OKTMO': ['11527000']},\n",
       " '100686526': {'OKTMO': ['11552000134']},\n",
       " '100690185': {'OKTMO': ['11514000326']},\n",
       " '100721871': {'OKTMO': ['11527000']},\n",
       " '100733984': {'OKTMO': ['11701000001']},\n",
       " '100740801': {'OKTMO': ['11552000243']},\n",
       " '100839964': {'OKTMO': ['11730000']},\n",
       " '100839965': {'OKTMO': ['11730000']},\n",
       " '100839966': {'OKTMO': ['11730000']},\n",
       " '100849141': {'OKTMO': ['11730000']},\n",
       " '100849143': {'OKTMO': ['11730000']},\n",
       " '100889693': {'OKTMO': ['11556000895']},\n",
       " '100943158': {'OKTMO': ['11730000']},\n",
       " '100943159': {'OKTMO': ['11730000']},\n",
       " '100943160': {'OKTMO': ['11730000']},\n",
       " '100943161': {'OKTMO': ['11730000']},\n",
       " '100943162': {'OKTMO': ['11730000']},\n",
       " '100943163': {'OKTMO': ['11730000']},\n",
       " '100943164': {'OKTMO': ['11730000']},\n",
       " '100943165': {'OKTMO': ['11730000']},\n",
       " '100943289': {'OKTMO': ['11527000688']},\n",
       " '100943291': {'OKTMO': ['11527000']},\n",
       " '100977614': {'OKTMO': ['11527000']},\n",
       " '101076539': {'OKTMO': ['11518000']},\n",
       " '101120904': {'OKTMO': ['11552000156']},\n",
       " '101170121': {'OKTMO': ['11518000826']},\n",
       " '101191342': {'OKTMO': ['11527000182']},\n",
       " '101233115': {'OKTMO': ['11701000001']},\n",
       " '101233243': {'OKTMO': ['11552000']},\n",
       " '101233245': {'OKTMO': ['11552000']},\n",
       " '101234398': {'OKTMO': ['11730000']},\n",
       " '101234400': {'OKTMO': ['11730000001']},\n",
       " '101234404': {'OKTMO': ['11730000']},\n",
       " '101276768': {'OKTMO': ['11550000066']},\n",
       " '101276965': {'OKTMO': ['11550000066']},\n",
       " '101276969': {'OKTMO': ['11550000066']},\n",
       " '101276972': {'OKTMO': ['11550000066']},\n",
       " '101276976': {'OKTMO': ['11550000066']},\n",
       " '101276979': {'OKTMO': ['11550000066']},\n",
       " '101276981': {'OKTMO': ['11550000066']},\n",
       " '101276984': {'OKTMO': ['11550000066']},\n",
       " '101276986': {'OKTMO': ['11550000066']},\n",
       " '101276994': {'OKTMO': ['11550000066']},\n",
       " '101276998': {'OKTMO': ['11550000066']},\n",
       " '101290187': {'OKTMO': ['11646432101']},\n",
       " '101291259': {'OKTMO': ['11701000001']},\n",
       " '101303199': {'OKTMO': ['11552000']},\n",
       " '101315443': {'OKTMO': ['11556000895']},\n",
       " '101366998': {'OKTMO': ['11552000']},\n",
       " '101367013': {'OKTMO': ['11552000']},\n",
       " '101367216': {'OKTMO': ['11552000']},\n",
       " '101367223': {'OKTMO': ['11552000']},\n",
       " '101367231': {'OKTMO': ['11552000']},\n",
       " '101367238': {'OKTMO': ['11552000']},\n",
       " '101369271': {'OKTMO': ['11552000']},\n",
       " '101388735': {'OKTMO': ['11552000']},\n",
       " '101388826': {'OKTMO': ['11552000']},\n",
       " '101388827': {'OKTMO': ['11552000']},\n",
       " '101388828': {'OKTMO': ['11552000']},\n",
       " '101430446': {'OKTMO': ['11646436111']},\n",
       " '101520861': {'OKTMO': ['11701000001']},\n",
       " '101560798': {'OKTMO': ['11530000132']},\n",
       " '101581119': {'OKTMO': ['11552000']},\n",
       " '101608274': {'OKTMO': ['11558000']},\n",
       " '101713305': {'OKTMO': ['11552000']},\n",
       " '101713308': {'OKTMO': ['11552000']},\n",
       " '101713310': {'OKTMO': ['11552000']},\n",
       " '101713315': {'OKTMO': ['11552000']},\n",
       " '101713318': {'OKTMO': ['11552000']},\n",
       " '101713320': {'OKTMO': ['11552000']},\n",
       " '101713324': {'OKTMO': ['11552000']},\n",
       " '101713328': {'OKTMO': ['11552000']},\n",
       " '101715492': {'OKTMO': ['11622406106']},\n",
       " '101723226': {'OKTMO': ['11622406101']},\n",
       " '101750200': {'OKTMO': ['11730000']},\n",
       " '101750201': {'OKTMO': ['11730000']},\n",
       " '101750202': {'OKTMO': ['11730000']},\n",
       " '101750203': {'OKTMO': ['11730000']},\n",
       " '101750204': {'OKTMO': ['11730000']},\n",
       " '101750205': {'OKTMO': ['11730000']},\n",
       " '101750206': {'OKTMO': ['11730000']},\n",
       " '101750207': {'OKTMO': ['11730000']},\n",
       " '101750208': {'OKTMO': ['11730000']},\n",
       " '101750209': {'OKTMO': ['11730000']},\n",
       " '101750210': {'OKTMO': ['11730000']},\n",
       " '101750211': {'OKTMO': ['11730000']},\n",
       " '101750212': {'OKTMO': ['11730000']},\n",
       " '101750213': {'OKTMO': ['11730000']},\n",
       " '101750214': {'OKTMO': ['11730000']},\n",
       " '101750230': {'OKTMO': ['11730000']},\n",
       " '101750231': {'OKTMO': ['11730000']},\n",
       " '101750232': {'OKTMO': ['11730000']},\n",
       " '101750233': {'OKTMO': ['11730000']},\n",
       " '101750234': {'OKTMO': ['11730000']},\n",
       " '101750235': {'OKTMO': ['11730000']},\n",
       " '101750236': {'OKTMO': ['11730000']},\n",
       " '101750237': {'OKTMO': ['11730000']},\n",
       " '101750238': {'OKTMO': ['11730000']},\n",
       " '101750239': {'OKTMO': ['11730000']},\n",
       " '101750240': {'OKTMO': ['11730000']},\n",
       " '101750241': {'OKTMO': ['11730000']},\n",
       " '101750242': {'OKTMO': ['11730000']},\n",
       " '101750243': {'OKTMO': ['11730000']},\n",
       " '101750244': {'OKTMO': ['11730000']},\n",
       " '101750245': {'OKTMO': ['11730000']},\n",
       " '101750246': {'OKTMO': ['11730000']},\n",
       " '101750247': {'OKTMO': ['11730000']},\n",
       " '101750248': {'OKTMO': ['11730000']},\n",
       " '101750249': {'OKTMO': ['11730000']},\n",
       " '101750250': {'OKTMO': ['11730000']},\n",
       " '101750251': {'OKTMO': ['11730000']},\n",
       " '101750252': {'OKTMO': ['11730000']},\n",
       " '101750253': {'OKTMO': ['11730000']},\n",
       " '101750254': {'OKTMO': ['11730000']},\n",
       " '101750255': {'OKTMO': ['11730000']},\n",
       " '101750256': {'OKTMO': ['11730000']},\n",
       " '101750257': {'OKTMO': ['11730000']},\n",
       " '101750258': {'OKTMO': ['11730000']},\n",
       " '101750259': {'OKTMO': ['11730000']},\n",
       " '101750260': {'OKTMO': ['11730000']},\n",
       " '101750261': {'OKTMO': ['11730000']},\n",
       " '101750262': {'OKTMO': ['11730000']},\n",
       " '101750263': {'OKTMO': ['11730000']},\n",
       " '101750264': {'OKTMO': ['11730000']},\n",
       " '101750265': {'OKTMO': ['11730000']},\n",
       " '101750266': {'OKTMO': ['11730000']},\n",
       " '101750267': {'OKTMO': ['11730000']},\n",
       " '101750268': {'OKTMO': ['11730000']},\n",
       " '101750269': {'OKTMO': ['11730000']},\n",
       " '101750270': {'OKTMO': ['11730000']},\n",
       " '101750271': {'OKTMO': ['11730000']},\n",
       " '101750272': {'OKTMO': ['11730000']},\n",
       " '101750273': {'OKTMO': ['11730000']},\n",
       " '101750274': {'OKTMO': ['11730000']},\n",
       " '101750275': {'OKTMO': ['11730000']},\n",
       " '101750276': {'OKTMO': ['11730000']},\n",
       " '101750277': {'OKTMO': ['11730000']},\n",
       " '101762407': {'OKTMO': ['11552000243']},\n",
       " '101796979': {'OKTMO': ['11550000066']},\n",
       " '101799427': {'OKTMO': ['11550000066']},\n",
       " '101799430': {'OKTMO': ['11550000066']},\n",
       " '101799431': {'OKTMO': ['11550000066']},\n",
       " '101799432': {'OKTMO': ['11550000066']},\n",
       " '101799433': {'OKTMO': ['11550000066']},\n",
       " '101799434': {'OKTMO': ['11550000066']},\n",
       " '101799435': {'OKTMO': ['11550000066']},\n",
       " '101799437': {'OKTMO': ['11550000066']},\n",
       " '101799438': {'OKTMO': ['11550000066']},\n",
       " '101850234': {'OKTMO': ['11730000']},\n",
       " '101850235': {'OKTMO': ['11730000']},\n",
       " '101850236': {'OKTMO': ['11730000']},\n",
       " '101850237': {'OKTMO': ['11730000']},\n",
       " '101850238': {'OKTMO': ['11730000']},\n",
       " '101850239': {'OKTMO': ['11730000']},\n",
       " '101850240': {'OKTMO': ['11730000']},\n",
       " '101850241': {'OKTMO': ['11554000']},\n",
       " '101903693': {'OKTMO': ['11552000']},\n",
       " '101930544': {'OKTMO': ['11646403116']},\n",
       " '101964964': {'OKTMO': ['11556000255']},\n",
       " '102022805': {'OKTMO': ['11527000']},\n",
       " '102037270': {'OKTMO': ['11527000']},\n",
       " '102050108': {'OKTMO': ['11552000']},\n",
       " '102050109': {'OKTMO': ['11552000']},\n",
       " '102050110': {'OKTMO': ['11552000']},\n",
       " '102050111': {'OKTMO': ['11552000']},\n",
       " '102050112': {'OKTMO': ['11552000']},\n",
       " '102050113': {'OKTMO': ['11552000']},\n",
       " '102050114': {'OKTMO': ['11552000']},\n",
       " '102050115': {'OKTMO': ['11552000']},\n",
       " '102107640': {'OKTMO': ['11552000']},\n",
       " '102239331': {'OKTMO': ['11527000']},\n",
       " '102279881': {'OKTMO': ['11725000001']},\n",
       " '102279882': {'OKTMO': ['11725000001']},\n",
       " '102286042': {'OKTMO': ['11725000001']},\n",
       " '102286043': {'OKTMO': ['11725000001']},\n",
       " '102286044': {'OKTMO': ['11725000001']},\n",
       " '102286045': {'OKTMO': ['11725000001']},\n",
       " '102286046': {'OKTMO': ['11725000001']},\n",
       " '102286047': {'OKTMO': ['11725000001']},\n",
       " '102286048': {'OKTMO': ['11725000001']},\n",
       " '102286049': {'OKTMO': ['11725000001']},\n",
       " '102286050': {'OKTMO': ['11725000001']},\n",
       " '102286051': {'OKTMO': ['11725000001']},\n",
       " '102286052': {'OKTMO': ['11725000001']},\n",
       " '102286053': {'OKTMO': ['11725000001']},\n",
       " '102286054': {'OKTMO': ['11725000001']},\n",
       " '102286055': {'OKTMO': ['11725000001']},\n",
       " '102286056': {'OKTMO': ['11725000001']},\n",
       " '102286057': {'OKTMO': ['11725000001']},\n",
       " '102286058': {'OKTMO': ['11725000001']},\n",
       " '102286059': {'OKTMO': ['11725000001']},\n",
       " '102286060': {'OKTMO': ['11725000001']},\n",
       " '102286061': {'OKTMO': ['11725000001']},\n",
       " '102286062': {'OKTMO': ['11725000001']},\n",
       " '102286063': {'OKTMO': ['11725000001']},\n",
       " '102286064': {'OKTMO': ['11725000001']},\n",
       " '102286065': {'OKTMO': ['11725000001']},\n",
       " '102286066': {'OKTMO': ['11725000001']},\n",
       " '102286067': {'OKTMO': ['11725000001']},\n",
       " '102286068': {'OKTMO': ['11725000001']},\n",
       " '102286069': {'OKTMO': ['11725000001']},\n",
       " '102286070': {'OKTMO': ['11725000001']},\n",
       " '102286071': {'OKTMO': ['11725000001']},\n",
       " '102286072': {'OKTMO': ['11725000001']},\n",
       " '102286073': {'OKTMO': ['11725000001']},\n",
       " '102352305': {'OKTMO': ['11622418196']},\n",
       " '102367655': {'OKTMO': ['11514000576']},\n",
       " '102410496': {'OKTMO': ['11552000279']},\n",
       " '102457466': {'OKTMO': ['11730000']},\n",
       " '102457467': {'OKTMO': ['11730000']},\n",
       " '102457468': {'OKTMO': ['11730000']},\n",
       " '102457469': {'OKTMO': ['11730000']},\n",
       " '102457470': {'OKTMO': ['11730000']},\n",
       " '102457471': {'OKTMO': ['11730000']},\n",
       " '102457472': {'OKTMO': ['11730000']},\n",
       " '102457473': {'OKTMO': ['11730000']},\n",
       " '102457474': {'OKTMO': ['11730000']},\n",
       " '102457475': {'OKTMO': ['11730000']},\n",
       " '102457476': {'OKTMO': ['11730000']},\n",
       " '102457477': {'OKTMO': ['11730000']},\n",
       " '102457478': {'OKTMO': ['11730000']},\n",
       " '102457479': {'OKTMO': ['11730000']},\n",
       " '102457480': {'OKTMO': ['11730000']},\n",
       " '102457481': {'OKTMO': ['11730000']},\n",
       " '102457482': {'OKTMO': ['11730000']},\n",
       " '102457483': {'OKTMO': ['11730000']},\n",
       " '102457484': {'OKTMO': ['11730000']},\n",
       " '102457485': {'OKTMO': ['11730000']},\n",
       " '102457486': {'OKTMO': ['11730000']},\n",
       " '102457487': {'OKTMO': ['11730000']},\n",
       " '102457488': {'OKTMO': ['11730000']},\n",
       " '102457489': {'OKTMO': ['11730000']},\n",
       " '102461344': {'OKTMO': ['11552000187']},\n",
       " '102461349': {'OKTMO': ['11552000243']},\n",
       " '102462098': {'OKTMO': ['11552000']},\n",
       " '102462099': {'OKTMO': ['11552000']},\n",
       " '102467455': {'OKTMO': ['11552000']},\n",
       " '102479790': {'OKTMO': ['11518000']},\n",
       " '102486916': {'OKTMO': ['11518000']},\n",
       " '102486919': {'OKTMO': ['11518000']},\n",
       " '102486922': {'OKTMO': ['11518000']},\n",
       " '102486926': {'OKTMO': ['11518000']},\n",
       " '102486931': {'OKTMO': ['11518000']},\n",
       " '102486932': {'OKTMO': ['11518000']},\n",
       " '102486937': {'OKTMO': ['11518000']},\n",
       " '102486941': {'OKTMO': ['11518000']},\n",
       " '102486946': {'OKTMO': ['11518000']},\n",
       " '102486948': {'OKTMO': ['11518000']},\n",
       " '102486952': {'OKTMO': ['11518000']},\n",
       " '102504023': {'OKTMO': ['11527000374']},\n",
       " '102633674': {'OKTMO': ['11622418161']},\n",
       " '102635883': {'OKTMO': ['11518000']},\n",
       " '102640653': {'OKTMO': ['11646436176']},\n",
       " '102679771': {'OKTMO': ['11556000545']},\n",
       " '102679772': {'OKTMO': ['11556000545']},\n",
       " '102679773': {'OKTMO': ['11556000545']},\n",
       " '102695639': {'OKTMO': ['11527000']},\n",
       " '102701202': {'OKTMO': ['11518000']},\n",
       " '102725983': {'OKTMO': ['11518000']},\n",
       " '102725984': {'OKTMO': ['11518000']},\n",
       " '102726161': {'OKTMO': ['11527000']},\n",
       " '102726162': {'OKTMO': ['11527000']},\n",
       " '102726163': {'OKTMO': ['11527000']},\n",
       " '102726164': {'OKTMO': ['11527000']},\n",
       " '102726165': {'OKTMO': ['11527000']},\n",
       " '102726166': {'OKTMO': ['11527000']},\n",
       " '102726167': {'OKTMO': ['11527000']},\n",
       " '102736366': {'OKTMO': ['11552000']},\n",
       " '102736367': {'OKTMO': ['11552000']},\n",
       " '102736368': {'OKTMO': ['11552000']},\n",
       " '102736369': {'OKTMO': ['11552000']},\n",
       " '102736370': {'OKTMO': ['11552000']},\n",
       " '102805219': {'OKTMO': ['11552000']},\n",
       " '102805220': {'OKTMO': ['11552000']},\n",
       " '102805221': {'OKTMO': ['11552000']},\n",
       " '102805222': {'OKTMO': ['11552000']},\n",
       " '102805223': {'OKTMO': ['11552000']},\n",
       " '102805224': {'OKTMO': ['11552000']},\n",
       " '102805225': {'OKTMO': ['11552000']},\n",
       " '102805226': {'OKTMO': ['11552000']},\n",
       " '102805227': {'OKTMO': ['11552000']},\n",
       " '102825734': {'OKTMO': ['11552000']},\n",
       " '102825735': {'OKTMO': ['11552000']},\n",
       " '102968912': {'OKTMO': ['11554000778']},\n",
       " '103066609': {'OKTMO': ['11554000']},\n",
       " '103082854': {'OKTMO': ['11605101']},\n",
       " '103127090': {'OKTMO': ['11605448241']},\n",
       " '103146655': {'OKTMO': ['11518000001']},\n",
       " '103169696': {'OKTMO': ['11554000340']},\n",
       " '103276357': {'OKTMO': ['11527000']},\n",
       " '103327827': {'OKTMO': ['11701000001']},\n",
       " '103351691': {'OKTMO': ['11712000']},\n",
       " '103401322': {'OKTMO': ['11518000']},\n",
       " '103401323': {'OKTMO': ['11518000']},\n",
       " '103497016': {'OKTMO': ['11605448166']},\n",
       " '103553122': {'OKTMO': ['11701000001']},\n",
       " '103653148': {'OKTMO': ['11554000']},\n",
       " '103694779': {'OKTMO': ['11627157']},\n",
       " '103745803': {'OKTMO': ['11701000001']},\n",
       " '103810194': {'OKTMO': ['11605432101']},\n",
       " '103851142': {'OKTMO': ['11527000']},\n",
       " '103902713': {'OKTMO': ['11511000762']},\n",
       " '103988296': {'OKTMO': ['11527000']},\n",
       " '104035682': {'OKTMO': ['11554000772']},\n",
       " '104128626': {'OKTMO': ['11622151051']},\n",
       " '104142405': {'OKTMO': ['11552000115']},\n",
       " '104145669': {'OKTMO': ['11518000562']},\n",
       " '104145690': {'OKTMO': ['11518000112']},\n",
       " '104190489': {'OKTMO': ['11518000']},\n",
       " '104202625': {'OKTMO': ['11552000']},\n",
       " '104236150': {'OKTMO': ['11730000']},\n",
       " '104236151': {'OKTMO': ['11730000']},\n",
       " '104236152': {'OKTMO': ['11730000']},\n",
       " '104236153': {'OKTMO': ['11730000']},\n",
       " '104236154': {'OKTMO': ['11730000']},\n",
       " '104236155': {'OKTMO': ['11730000']},\n",
       " '104236156': {'OKTMO': ['11730000']},\n",
       " '104236157': {'OKTMO': ['11730000']},\n",
       " '104236158': {'OKTMO': ['11730000']},\n",
       " '104236159': {'OKTMO': ['11730000']},\n",
       " '104236160': {'OKTMO': ['11730000']},\n",
       " '104236161': {'OKTMO': ['11730000']},\n",
       " '104236162': {'OKTMO': ['11730000']},\n",
       " '104236163': {'OKTMO': ['11730000']},\n",
       " '104236164': {'OKTMO': ['11730000']},\n",
       " '104236165': {'OKTMO': ['11730000']},\n",
       " '104236166': {'OKTMO': ['11730000']},\n",
       " '104236167': {'OKTMO': ['11730000']},\n",
       " '104236168': {'OKTMO': ['11730000']},\n",
       " '104236169': {'OKTMO': ['11730000']},\n",
       " '104236170': {'OKTMO': ['11730000']},\n",
       " '104236171': {'OKTMO': ['11730000']},\n",
       " '104236172': {'OKTMO': ['11730000']},\n",
       " '104236173': {'OKTMO': ['11730000']},\n",
       " '104236174': {'OKTMO': ['11730000']},\n",
       " '104236175': {'OKTMO': ['11730000']},\n",
       " '104236176': {'OKTMO': ['11730000']},\n",
       " '104236177': {'OKTMO': ['11730000']},\n",
       " '104236178': {'OKTMO': ['11730000']},\n",
       " '104236179': {'OKTMO': ['11730000']},\n",
       " '104236180': {'OKTMO': ['11730000']},\n",
       " '104236186': {'OKTMO': ['11730000']},\n",
       " '104236187': {'OKTMO': ['11730000']},\n",
       " '104236188': {'OKTMO': ['11730000']},\n",
       " '104236189': {'OKTMO': ['11730000']},\n",
       " '104236190': {'OKTMO': ['11730000']},\n",
       " '104236191': {'OKTMO': ['11730000']},\n",
       " '104236192': {'OKTMO': ['11730000']},\n",
       " '104236193': {'OKTMO': ['11730000']},\n",
       " '104236194': {'OKTMO': ['11730000']},\n",
       " '104236195': {'OKTMO': ['11730000']},\n",
       " '104236196': {'OKTMO': ['11730000']},\n",
       " '104236197': {'OKTMO': ['11730000']},\n",
       " '104236198': {'OKTMO': ['11730000']},\n",
       " '104236199': {'OKTMO': ['11730000']},\n",
       " '104236200': {'OKTMO': ['11730000']},\n",
       " '104236201': {'OKTMO': ['11730000']},\n",
       " '104236202': {'OKTMO': ['11730000']},\n",
       " '104236203': {'OKTMO': ['11730000']},\n",
       " '104236204': {'OKTMO': ['11730000']},\n",
       " '104236205': {'OKTMO': ['11730000']},\n",
       " '104236206': {'OKTMO': ['11730000']},\n",
       " '104236207': {'OKTMO': ['11730000']},\n",
       " '104236208': {'OKTMO': ['11730000']},\n",
       " '104236209': {'OKTMO': ['11730000']},\n",
       " '104236210': {'OKTMO': ['11730000']},\n",
       " '104236211': {'OKTMO': ['11730000']},\n",
       " '104236212': {'OKTMO': ['11730000']},\n",
       " '104236213': {'OKTMO': ['11730000']},\n",
       " '104236214': {'OKTMO': ['11730000']},\n",
       " '104236215': {'OKTMO': ['11730000']},\n",
       " '104236216': {'OKTMO': ['11730000']},\n",
       " '104236217': {'OKTMO': ['11730000']},\n",
       " '104236218': {'OKTMO': ['11730000']},\n",
       " '104236219': {'OKTMO': ['11730000']},\n",
       " '104236220': {'OKTMO': ['11730000']},\n",
       " '104236221': {'OKTMO': ['11730000']},\n",
       " '104236222': {'OKTMO': ['11730000']},\n",
       " '104236223': {'OKTMO': ['11730000']},\n",
       " '104236224': {'OKTMO': ['11730000']},\n",
       " '104236225': {'OKTMO': ['11730000']},\n",
       " '104378168': {'OKTMO': ['11527000']},\n",
       " '104408894': {'OKTMO': ['11552000']},\n",
       " '104410976': {'OKTMO': ['11544000']},\n",
       " '104415987': {'OKTMO': ['11518000']},\n",
       " '104478662': {'OKTMO': ['11605101']},\n",
       " '104490496': {'OKTMO': ['11527000']},\n",
       " '104560385': {'OKTMO': ['11730000']},\n",
       " '104560386': {'OKTMO': ['11730000']},\n",
       " '104560387': {'OKTMO': ['11730000']},\n",
       " '104560388': {'OKTMO': ['11730000']},\n",
       " '104560389': {'OKTMO': ['11730000']},\n",
       " '104560390': {'OKTMO': ['11730000']},\n",
       " '104560391': {'OKTMO': ['11730000']},\n",
       " '104560393': {'OKTMO': ['11730000']},\n",
       " '104560394': {'OKTMO': ['11730000']},\n",
       " '104560395': {'OKTMO': ['11730000']},\n",
       " '104560396': {'OKTMO': ['11730000']},\n",
       " '104591911': {'OKTMO': ['11605418136']},\n",
       " '104709858': {'OKTMO': ['11554000772']},\n",
       " '104735761': {'OKTMO': ['11527000246']},\n",
       " '104735787': {'OKTMO': ['11527000246']},\n",
       " '104735813': {'OKTMO': ['11527000354']},\n",
       " '104823585': {'OKTMO': ['11710000001']},\n",
       " '104861105': {'OKTMO': ['11646101001']},\n",
       " '104903578': {'OKTMO': ['11527000']},\n",
       " '104969210': {'OKTMO': ['11605448241']},\n",
       " '104969502': {'OKTMO': ['11605448131']},\n",
       " '105007850': {'OKTMO': ['11511000430']},\n",
       " '105008618': {'OKTMO': ['11518000']},\n",
       " '105018229': {'OKTMO': ['11552000']},\n",
       " '105091269': {'OKTMO': ['11552000210']},\n",
       " '105154692': {'OKTMO': ['11730000']},\n",
       " '105154722': {'OKTMO': ['11552000']},\n",
       " '105338026': {'OKTMO': ['11701000001']},\n",
       " '105472789': {'OKTMO': ['11730000']},\n",
       " '105477634': {'OKTMO': ['11701000001']},\n",
       " '105556086': {'OKTMO': ['11730000']},\n",
       " '105585455': {'OKTMO': ['11552000']},\n",
       " '105617074': {'OKTMO': ['11701000001']},\n",
       " '105635366': {'OKTMO': ['11605448196']},\n",
       " '105661430': {'OKTMO': ['11550000427']},\n",
       " '105672028': {'OKTMO': ['11556000937']},\n",
       " '105682218': {'OKTMO': ['11552000210']},\n",
       " '105686637': {'OKTMO': ['11527000']},\n",
       " '105749820': {'OKTMO': ['11725000001']},\n",
       " '105749821': {'OKTMO': ['11725000001']},\n",
       " '105749822': {'OKTMO': ['11725000001']},\n",
       " '105749823': {'OKTMO': ['11725000001']},\n",
       " '105749824': {'OKTMO': ['11725000001']},\n",
       " '105749825': {'OKTMO': ['11725000001']},\n",
       " '105749826': {'OKTMO': ['11725000001']},\n",
       " '105749827': {'OKTMO': ['11725000001']},\n",
       " '105749828': {'OKTMO': ['11725000001']},\n",
       " '105749829': {'OKTMO': ['11725000001']},\n",
       " '156796243': {'OKTMO': ['11552000282']},\n",
       " '156851033': {'OKTMO': ['11544000']},\n",
       " '156856983': {'OKTMO': ['11527000057']},\n",
       " '156980690': {'OKTMO': ['11552000217']},\n",
       " '157396145': {'OKTMO': ['11552000']},\n",
       " '157407639': {'OKTMO': ['11552000286']},\n",
       " '157426764': {'OKTMO': ['11725000001']},\n",
       " '157426765': {'OKTMO': ['11725000001']},\n",
       " '157426766': {'OKTMO': ['11725000001']},\n",
       " '157426767': {'OKTMO': ['11725000001']},\n",
       " '157426768': {'OKTMO': ['11725000001']},\n",
       " '157426769': {'OKTMO': ['11725000001']},\n",
       " '157426770': {'OKTMO': ['11725000001']},\n",
       " '157426771': {'OKTMO': ['11725000001']},\n",
       " '157426772': {'OKTMO': ['11725000001']},\n",
       " '157426773': {'OKTMO': ['11725000001']},\n",
       " '157426774': {'OKTMO': ['11725000001']},\n",
       " '157426775': {'OKTMO': ['11725000001']},\n",
       " '157426776': {'OKTMO': ['11725000001']},\n",
       " '157426777': {'OKTMO': ['11725000001']},\n",
       " '157426778': {'OKTMO': ['11725000001']},\n",
       " '157426779': {'OKTMO': ['11725000001']},\n",
       " '157426780': {'OKTMO': ['11725000001']},\n",
       " '157426781': {'OKTMO': ['11725000001']},\n",
       " '157455355': {'OKTMO': ['11554000']},\n",
       " '157456529': {'OKTMO': ['11635157051']},\n",
       " '157460753': {'OKTMO': ['11635157051']},\n",
       " '157607755': {'OKTMO': ['11527000057']},\n",
       " '157631446': {'OKTMO': ['11554000']},\n",
       " '157664567': {'OKTMO': ['11550000730']},\n",
       " '157698830': {'OKTMO': ['11552000281']},\n",
       " '157699702': {'OKTMO': ['11518000']},\n",
       " '157721083': {'OKTMO': ['11544000']},\n",
       " '157721103': {'OKTMO': ['11556000']},\n",
       " '157721129': {'OKTMO': ['11527000']},\n",
       " '157731221': {'OKTMO': ['11518000']},\n",
       " '157735857': {'OKTMO': ['11558000']},\n",
       " '157737607': {'OKTMO': ['11542000']},\n",
       " '157744348': {'OKTMO': ['11538000']},\n",
       " '157783338': {'OKTMO': ['11518000']},\n",
       " '157785083': {'OKTMO': ['11518000']},\n",
       " '157785107': {'OKTMO': ['11518000']},\n",
       " '157785330': {'OKTMO': ['11518000']},\n",
       " '157785331': {'OKTMO': ['11518000']},\n",
       " '157785332': {'OKTMO': ['11518000']},\n",
       " '157785333': {'OKTMO': ['11518000']},\n",
       " '157785334': {'OKTMO': ['11518000']},\n",
       " '157808995': {'OKTMO': ['11730000']},\n",
       " '157808996': {'OKTMO': ['11730000']},\n",
       " '157808997': {'OKTMO': ['11730000']},\n",
       " '157808998': {'OKTMO': ['11730000']},\n",
       " '157808999': {'OKTMO': ['11730000']},\n",
       " '157809000': {'OKTMO': ['11730000']},\n",
       " '157809001': {'OKTMO': ['11730000']},\n",
       " '157809002': {'OKTMO': ['11730000']},\n",
       " '157809003': {'OKTMO': ['11730000']},\n",
       " '157809004': {'OKTMO': ['11730000']},\n",
       " '157809005': {'OKTMO': ['11730000']},\n",
       " '157809006': {'OKTMO': ['11730000']},\n",
       " '157809007': {'OKTMO': ['11730000']},\n",
       " '157809008': {'OKTMO': ['11730000']},\n",
       " '157809009': {'OKTMO': ['11730000']},\n",
       " '157861083': {'OKTMO': ['11552000286']},\n",
       " '157882075': {'OKTMO': ['11552000']},\n",
       " '157924581': {'OKTMO': ['11554000']},\n",
       " '157993701': {'OKTMO': ['11527000246']},\n",
       " '157993702': {'OKTMO': ['11527000246']},\n",
       " '157993703': {'OKTMO': ['11527000246']},\n",
       " '157993704': {'OKTMO': ['11527000246']},\n",
       " '157993705': {'OKTMO': ['11527000246']},\n",
       " '157993706': {'OKTMO': ['11527000246']},\n",
       " '157993707': {'OKTMO': ['11527000246']},\n",
       " '157993708': {'OKTMO': ['11527000246']},\n",
       " '157993709': {'OKTMO': ['11527000246']},\n",
       " '158040959': {'OKTMO': ['11646101']},\n",
       " '158048170': {'OKTMO': ['11552000202']},\n",
       " '158072280': {'OKTMO': ['11542000']},\n",
       " '158074016': {'OKTMO': ['11542000']},\n",
       " '158093044': {'OKTMO': ['11646101']},\n",
       " '158100832': {'OKTMO': ['11527000']},\n",
       " '158137218': {'OKTMO': ['11730000']},\n",
       " '158181780': {'OKTMO': ['11518000']},\n",
       " '158186659': {'OKTMO': ['11527000']},\n",
       " '158250773': {'OKTMO': ['11701000001']},\n",
       " '158276192': {'OKTMO': ['11518000']},\n",
       " '158276195': {'OKTMO': ['11518000']},\n",
       " '158276196': {'OKTMO': ['11518000']},\n",
       " '158276203': {'OKTMO': ['11518000']},\n",
       " '158285837': {'OKTMO': ['11552000']},\n",
       " '158292483': {'OKTMO': ['11518000']},\n",
       " '158292498': {'OKTMO': ['11518000']},\n",
       " '158292499': {'OKTMO': ['11518000']},\n",
       " '158292500': {'OKTMO': ['11518000']},\n",
       " '158297674': {'OKTMO': ['11635420']},\n",
       " '158334735': {'OKTMO': ['11542000']},\n",
       " '158337187': {'OKTMO': ['11542000']},\n",
       " '158344492': {'OKTMO': ['11527000606']},\n",
       " '158370472': {'OKTMO': ['11730000']},\n",
       " '158370473': {'OKTMO': ['11730000']},\n",
       " '158371784': {'OKTMO': ['11730000']},\n",
       " '158371785': {'OKTMO': ['11730000']},\n",
       " '158371786': {'OKTMO': ['11730000']},\n",
       " '158371787': {'OKTMO': ['11730000']},\n",
       " '158371788': {'OKTMO': ['11730000']},\n",
       " '158371789': {'OKTMO': ['11730000']},\n",
       " '158377291': {'OKTMO': ['11558000001']},\n",
       " '158378937': {'OKTMO': ['11552000282']},\n",
       " '158449314': {'OKTMO': ['11552000282']},\n",
       " '158466164': {'OKTMO': ['11552000']},\n",
       " '158466177': {'OKTMO': ['11552000']},\n",
       " '158466178': {'OKTMO': ['11552000']},\n",
       " '158466179': {'OKTMO': ['11552000']},\n",
       " '158466180': {'OKTMO': ['11552000']},\n",
       " '158466184': {'OKTMO': ['11552000']},\n",
       " '158466185': {'OKTMO': ['11552000']},\n",
       " '158466186': {'OKTMO': ['11552000']},\n",
       " '158466187': {'OKTMO': ['11552000']},\n",
       " '158466188': {'OKTMO': ['11552000']},\n",
       " '158466191': {'OKTMO': ['11552000']},\n",
       " '158466192': {'OKTMO': ['11552000']},\n",
       " '158466193': {'OKTMO': ['11552000']},\n",
       " '158466194': {'OKTMO': ['11552000']},\n",
       " '158466195': {'OKTMO': ['11552000']},\n",
       " '158484261': {'OKTMO': ['11554000340']},\n",
       " '158511407': {'OKTMO': ['11552000']},\n",
       " '158514039': {'OKTMO': ['11556000']},\n",
       " '158514051': {'OKTMO': ['11556000']},\n",
       " '158541051': {'OKTMO': ['11730000']},\n",
       " '158553071': {'OKTMO': ['11552000202']},\n",
       " '158590137': {'OKTMO': ['11527000']},\n",
       " '158590164': {'OKTMO': ['11527000132']},\n",
       " '158599587': {'OKTMO': ['11518000193']},\n",
       " '158600054': {'OKTMO': ['11550000066']},\n",
       " '158600937': {'OKTMO': ['11550000583']},\n",
       " '158600947': {'OKTMO': ['11550000748']},\n",
       " '158600951': {'OKTMO': ['11550000619']},\n",
       " '158600954': {'OKTMO': ['11550000592']},\n",
       " '158603993': {'OKTMO': ['11518000']},\n",
       " '158612682': {'OKTMO': ['11527000']},\n",
       " '158686667': {'OKTMO': ['11527000']},\n",
       " '158686677': {'OKTMO': ['11527000']},\n",
       " '158699717': {'OKTMO': ['11552000']},\n",
       " '158747113': {'OKTMO': ['11544000']},\n",
       " '158747118': {'OKTMO': ['11544000']},\n",
       " '158747122': {'OKTMO': ['11544000']},\n",
       " '158747123': {'OKTMO': ['11544000']},\n",
       " '158747220': {'OKTMO': ['11544000']},\n",
       " '158747223': {'OKTMO': ['11544000']},\n",
       " '158747226': {'OKTMO': ['11544000']},\n",
       " '158747227': {'OKTMO': ['11544000']},\n",
       " '158747250': {'OKTMO': ['11544000']},\n",
       " '158747253': {'OKTMO': ['11544000']},\n",
       " '158747262': {'OKTMO': ['11544000']},\n",
       " '158747302': {'OKTMO': ['11544000']},\n",
       " '158747305': {'OKTMO': ['11544000']},\n",
       " '158749708': {'OKTMO': ['11544000']},\n",
       " '158750357': {'OKTMO': ['11544000']},\n",
       " '158766545': {'OKTMO': ['11544000']},\n",
       " '158849334': {'OKTMO': ['11552000']},\n",
       " '158864986': {'OKTMO': ['11527000']},\n",
       " '158864987': {'OKTMO': ['11527000']},\n",
       " '158888171': {'OKTMO': ['11712000']},\n",
       " '158895705': {'OKTMO': ['11550000']},\n",
       " '158916361': {'OKTMO': ['11544000']},\n",
       " '158916362': {'OKTMO': ['11544000']},\n",
       " '158916363': {'OKTMO': ['11544000']},\n",
       " '158938677': {'OKTMO': ['11558000']},\n",
       " '158985272': {'OKTMO': ['11558000']},\n",
       " '158985273': {'OKTMO': ['11558000']},\n",
       " '158996873': {'OKTMO': ['11554000475']},\n",
       " '159001065': {'OKTMO': ['11605448121']},\n",
       " '159001073': {'OKTMO': ['11605448121']},\n",
       " '159001081': {'OKTMO': ['11605448121']},\n",
       " '159031073': {'OKTMO': ['11544000']},\n",
       " '159106836': {'OKTMO': ['11550000']},\n",
       " '159167207': {'OKTMO': ['11527000']},\n",
       " '159200729': {'OKTMO': ['11544000']},\n",
       " '159200730': {'OKTMO': ['11544000']},\n",
       " '159203672': {'OKTMO': ['11552000']},\n",
       " '159203673': {'OKTMO': ['11552000']},\n",
       " '159272789': {'OKTMO': ['11558000']},\n",
       " '159275330': {'OKTMO': ['11527000658']},\n",
       " '159275331': {'OKTMO': ['11527000658']},\n",
       " '159275332': {'OKTMO': ['11527000658']},\n",
       " '159275333': {'OKTMO': ['11527000322']},\n",
       " '159299041': {'OKTMO': ['11527000']},\n",
       " '159321251': {'OKTMO': ['11527000430']},\n",
       " '159374715': {'OKTMO': ['11605418141']},\n",
       " '159375997': {'OKTMO': ['11635157']},\n",
       " '159393335': {'OKTMO': ['11635157']},\n",
       " '159542441': {'OKTMO': ['11701000001']},\n",
       " '159542933': {'OKTMO': ['11550000051']},\n",
       " '159575589': {'OKTMO': ['11550000']},\n",
       " '159586415': {'OKTMO': ['11544000']},\n",
       " '159631069': {'OKTMO': ['11544000']},\n",
       " '159631112': {'OKTMO': ['11544000']},\n",
       " '159643981': {'OKTMO': ['11552000']},\n",
       " '159645174': {'OKTMO': ['11544000']},\n",
       " '159683413': {'OKTMO': ['11527000']},\n",
       " '159692519': {'OKTMO': ['11730000']},\n",
       " '159692520': {'OKTMO': ['11730000']},\n",
       " '159692521': {'OKTMO': ['11730000']},\n",
       " '159692522': {'OKTMO': ['11730000']},\n",
       " '159692523': {'OKTMO': ['11730000']},\n",
       " '159692524': {'OKTMO': ['11730000']},\n",
       " '159692525': {'OKTMO': ['11730000']},\n",
       " '159692526': {'OKTMO': ['11730000']},\n",
       " '159692527': {'OKTMO': ['11730000']},\n",
       " '159692528': {'OKTMO': ['11730000']},\n",
       " '159719491': {'OKTMO': ['11710000001']},\n",
       " '159719492': {'OKTMO': ['11710000001']},\n",
       " '159725299': {'OKTMO': ['11527000052']},\n",
       " '159781996': {'OKTMO': ['11544000']},\n",
       " '159781997': {'OKTMO': ['11544000']},\n",
       " '159811825': {'OKTMO': ['11544000']},\n",
       " '159811829': {'OKTMO': ['11544000']},\n",
       " '160154358': {'OKTMO': ['11550000739']},\n",
       " '160165385': {'OKTMO': ['11544000']},\n",
       " '160201932': {'OKTMO': ['11518000']},\n",
       " '160280801': {'OKTMO': ['11548000101']},\n",
       " '160362463': {'OKTMO': ['11530000406']},\n",
       " '160362464': {'OKTMO': ['11530000344']},\n",
       " '160391611': {'OKTMO': ['11635420']},\n",
       " '160419422': {'OKTMO': ['11538000101']},\n",
       " '160430460': {'OKTMO': ['11635157']},\n",
       " '160453736': {'OKTMO': ['11552000243']},\n",
       " '160453737': {'OKTMO': ['11552000243']},\n",
       " '160459766': {'OKTMO': ['11558000']},\n",
       " '160478615': {'OKTMO': ['11552000']},\n",
       " '160478709': {'OKTMO': ['11552000']},\n",
       " '160478788': {'OKTMO': ['11552000']},\n",
       " '160478806': {'OKTMO': ['11552000']},\n",
       " '160478807': {'OKTMO': ['11552000']},\n",
       " '160478808': {'OKTMO': ['11552000']},\n",
       " '160478809': {'OKTMO': ['11552000']},\n",
       " '160478810': {'OKTMO': ['11552000']},\n",
       " '160478811': {'OKTMO': ['11552000']},\n",
       " '160478812': {'OKTMO': ['11552000']},\n",
       " '160478813': {'OKTMO': ['11552000']},\n",
       " '160478814': {'OKTMO': ['11552000']},\n",
       " '160478815': {'OKTMO': ['11552000']},\n",
       " '160478816': {'OKTMO': ['11552000']},\n",
       " '160490961': {'OKTMO': ['11514000556']},\n",
       " '160562692': {'OKTMO': ['11552000']},\n",
       " '160589906': {'OKTMO': ['11527000']},\n",
       " '160605006': {'OKTMO': ['11527000']},\n",
       " '160605008': {'OKTMO': ['11548000204']},\n",
       " '160626539': {'OKTMO': ['11527000']},\n",
       " '160628119': {'OKTMO': ['11527000']},\n",
       " '160628120': {'OKTMO': ['11527000']},\n",
       " '160628910': {'OKTMO': ['11527000']},\n",
       " '160675227': {'OKTMO': ['11552000']},\n",
       " '160713557': {'OKTMO': ['11527000']},\n",
       " '160793412': {'OKTMO': ['11527000057']},\n",
       " '160794387': {'OKTMO': ['11648408']},\n",
       " '160795430': {'OKTMO': ['11552000']},\n",
       " '160795441': {'OKTMO': ['11552000']},\n",
       " '160808675': {'OKTMO': ['11527000']},\n",
       " '160815327': {'OKTMO': ['11646432']},\n",
       " '160867987': {'OKTMO': ['11518000']},\n",
       " '160878106': {'OKTMO': ['11648408']},\n",
       " '160917092': {'OKTMO': ['11552000271']},\n",
       " '160920289': {'OKTMO': ['11605428101']},\n",
       " '161002161': {'OKTMO': ['11527000']},\n",
       " '161026903': {'OKTMO': ['11518000793']},\n",
       " '161029296': {'OKTMO': ['11518000']},\n",
       " '161257382': {'OKTMO': ['11708000001']},\n",
       " '161313163': {'OKTMO': ['11708000001']},\n",
       " '161313166': {'OKTMO': ['11708000001']},\n",
       " '161313167': {'OKTMO': ['11708000001']},\n",
       " '161313168': {'OKTMO': ['11708000001']},\n",
       " '161313169': {'OKTMO': ['11708000001']},\n",
       " '161313170': {'OKTMO': ['11708000001']},\n",
       " '161313171': {'OKTMO': ['11708000001']},\n",
       " '161313175': {'OKTMO': ['11708000001']},\n",
       " '161313176': {'OKTMO': ['11708000001']},\n",
       " '161313177': {'OKTMO': ['11708000001']},\n",
       " '161313178': {'OKTMO': ['11708000001']},\n",
       " '161313179': {'OKTMO': ['11708000001']},\n",
       " '161313180': {'OKTMO': ['11708000001']},\n",
       " '161313181': {'OKTMO': ['11708000001']},\n",
       " '161313182': {'OKTMO': ['11708000001']},\n",
       " '161313183': {'OKTMO': ['11708000001']},\n",
       " '161313184': {'OKTMO': ['11708000001']},\n",
       " '161313185': {'OKTMO': ['11708000001']},\n",
       " '161313186': {'OKTMO': ['11708000001']},\n",
       " '161313187': {'OKTMO': ['11708000001']},\n",
       " '161313188': {'OKTMO': ['11708000001']},\n",
       " '161313189': {'OKTMO': ['11708000001']},\n",
       " '161330219': {'OKTMO': ['11552000']},\n",
       " '161331222': {'OKTMO': ['11701000001']},\n",
       " '161457717': {'OKTMO': ['11725000001']},\n",
       " '161457734': {'OKTMO': ['11725000001']},\n",
       " '161457745': {'OKTMO': ['11725000001']},\n",
       " '161457752': {'OKTMO': ['11725000001']},\n",
       " '161457762': {'OKTMO': ['11725000001']},\n",
       " '161457772': {'OKTMO': ['11725000001']},\n",
       " '161457777': {'OKTMO': ['11725000001']},\n",
       " '161457781': {'OKTMO': ['11725000001']},\n",
       " '161457786': {'OKTMO': ['11725000001']},\n",
       " '161457788': {'OKTMO': ['11725000001']},\n",
       " '161457794': {'OKTMO': ['11725000001']},\n",
       " '161457797': {'OKTMO': ['11725000001']},\n",
       " '161457815': {'OKTMO': ['11725000001']},\n",
       " '161457820': {'OKTMO': ['11725000001']},\n",
       " '161457822': {'OKTMO': ['11725000001']},\n",
       " '161457826': {'OKTMO': ['11725000001']},\n",
       " '161457832': {'OKTMO': ['11725000001']},\n",
       " '161457850': {'OKTMO': ['11725000001']},\n",
       " '161457855': {'OKTMO': ['11725000001']},\n",
       " '161457864': {'OKTMO': ['11725000001']},\n",
       " '161457871': {'OKTMO': ['11725000001']},\n",
       " '161457876': {'OKTMO': ['11725000001']},\n",
       " '161457886': {'OKTMO': ['11725000001']},\n",
       " '161457891': {'OKTMO': ['11725000001']},\n",
       " '161457897': {'OKTMO': ['11725000001']},\n",
       " '161457912': {'OKTMO': ['11725000001']},\n",
       " '161457915': {'OKTMO': ['11725000001']},\n",
       " '161483816': {'OKTMO': ['11552000']},\n",
       " '161488336': {'OKTMO': ['11544000']},\n",
       " '161493101': {'OKTMO': ['11527000']},\n",
       " '161535764': {'OKTMO': ['11552000232']},\n",
       " '161566731': {'OKTMO': ['11527000']},\n",
       " '161624931': {'OKTMO': ['11527000']},\n",
       " '161626419': {'OKTMO': ['11552000']},\n",
       " '161626420': {'OKTMO': ['11552000']},\n",
       " '161626421': {'OKTMO': ['11552000']},\n",
       " '161639630': {'OKTMO': ['11527000']},\n",
       " '161820570': {'OKTMO': ['11527000186']},\n",
       " '161833524': {'OKTMO': ['11527000']},\n",
       " '161833538': {'OKTMO': ['11527000']},\n",
       " '161880691': {'OKTMO': ['11527000']},\n",
       " '161893461': {'OKTMO': ['11527000']},\n",
       " '161895799': {'OKTMO': ['11527000']},\n",
       " '161928911': {'OKTMO': ['11652452']},\n",
       " '161929012': {'OKTMO': ['11552000']},\n",
       " '161962235': {'OKTMO': ['11552000']},\n",
       " '161962236': {'OKTMO': ['11552000']},\n",
       " '161962237': {'OKTMO': ['11552000']},\n",
       " '161962238': {'OKTMO': ['11552000']},\n",
       " '161980616': {'OKTMO': ['11552000']},\n",
       " '161980617': {'OKTMO': ['11552000']},\n",
       " '161980618': {'OKTMO': ['11552000']},\n",
       " '161980619': {'OKTMO': ['11552000']},\n",
       " '161980620': {'OKTMO': ['11552000']},\n",
       " '161980621': {'OKTMO': ['11552000']},\n",
       " '161980622': {'OKTMO': ['11552000']},\n",
       " '161980623': {'OKTMO': ['11552000']},\n",
       " '161980624': {'OKTMO': ['11552000']},\n",
       " '161980625': {'OKTMO': ['11552000']},\n",
       " '161980626': {'OKTMO': ['11552000']},\n",
       " '161980627': {'OKTMO': ['11552000']},\n",
       " '161990909': {'OKTMO': ['11527000']},\n",
       " '162004286': {'OKTMO': ['11715000']},\n",
       " '162004287': {'OKTMO': ['11715000001']},\n",
       " '162004289': {'OKTMO': ['11715000']},\n",
       " '162005927': {'OKTMO': ['11730000']},\n",
       " '162005928': {'OKTMO': ['11730000']},\n",
       " '162005929': {'OKTMO': ['11730000']},\n",
       " '162005930': {'OKTMO': ['11730000']},\n",
       " '162005931': {'OKTMO': ['11730000']},\n",
       " '162005932': {'OKTMO': ['11730000']},\n",
       " '162005933': {'OKTMO': ['11730000']},\n",
       " '162030634': {'OKTMO': ['11548000']},\n",
       " '162031408': {'OKTMO': ['11530000']},\n",
       " '162033520': {'OKTMO': ['11552000']},\n",
       " '162052437': {'OKTMO': ['11605448151']},\n",
       " '162062752': {'OKTMO': ['11701000001']},\n",
       " '162077843': {'OKTMO': ['11715000001']},\n",
       " '162077844': {'OKTMO': ['11715000001']},\n",
       " '162077845': {'OKTMO': ['11715000001']},\n",
       " '162077846': {'OKTMO': ['11715000001']},\n",
       " '162077847': {'OKTMO': ['11715000001']},\n",
       " '162077848': {'OKTMO': ['11715000001']},\n",
       " '162077849': {'OKTMO': ['11715000001']},\n",
       " '162077850': {'OKTMO': ['11715000001']},\n",
       " '162077851': {'OKTMO': ['11715000001']},\n",
       " '162095729': {'OKTMO': ['11646101001']},\n",
       " '162104195': {'OKTMO': ['11635420']},\n",
       " '162108644': {'OKTMO': ['11527000']},\n",
       " '162113125': {'OKTMO': ['11527000696']},\n",
       " '162114602': {'OKTMO': ['11635157051']},\n",
       " '162123285': {'OKTMO': ['11527000']},\n",
       " '162139179': {'OKTMO': ['11527000']},\n",
       " '162225555': {'OKTMO': ['11554000340']},\n",
       " '162244049': {'OKTMO': ['11605444136']},\n",
       " '162244050': {'OKTMO': ['11605444136']},\n",
       " '162244051': {'OKTMO': ['11605444136']},\n",
       " '162244052': {'OKTMO': ['11605444136']},\n",
       " '162244053': {'OKTMO': ['11605444136']},\n",
       " '162244054': {'OKTMO': ['11605444136']},\n",
       " '162244055': {'OKTMO': ['11605444136']},\n",
       " '162314150': {'OKTMO': ['11552000']},\n",
       " '162330548': {'OKTMO': ['11527000']},\n",
       " '162355871': {'OKTMO': ['11715000']},\n",
       " '162386215': {'OKTMO': ['11527000']},\n",
       " '162407277': {'OKTMO': ['11730000']},\n",
       " '162489014': {'OKTMO': ['11558000']},\n",
       " '162499499': {'OKTMO': ['11527000']},\n",
       " '162499501': {'OKTMO': ['11527000']},\n",
       " '162502398': {'OKTMO': ['11527000']},\n",
       " '162502399': {'OKTMO': ['11527000']},\n",
       " '162502401': {'OKTMO': ['11527000']},\n",
       " '162529098': {'OKTMO': ['11527000']},\n",
       " '162568267': {'OKTMO': ['11527000']},\n",
       " '162585619': {'OKTMO': ['11552000']},\n",
       " '162585620': {'OKTMO': ['11552000']},\n",
       " '162585621': {'OKTMO': ['11552000']},\n",
       " '162585622': {'OKTMO': ['11552000']},\n",
       " '162585623': {'OKTMO': ['11552000']},\n",
       " '162624181': {'OKTMO': ['11544000']},\n",
       " '162629861': {'OKTMO': ['11556000']},\n",
       " '162656754': {'OKTMO': ['11542000241']},\n",
       " '438356': {'OKTMO': ['11708000001']},\n",
       " '438363': {'OKTMO': ['11725000001']},\n",
       " '438387': {'OKTMO': ['11701000001']},\n",
       " '438391': {'OKTMO': ['11701000']},\n",
       " '438421': {'OKTMO': ['11701000001']},\n",
       " '438426': {'OKTMO': ['11701000']},\n",
       " '438428': {'OKTMO': ['11701000001']},\n",
       " '438438': {'OKTMO': ['11708000001']},\n",
       " '438448': {'OKTMO': ['11730000001']},\n",
       " '438451': {'OKTMO': ['11715000']},\n",
       " '438461': {'OKTMO': ['11715000']},\n",
       " '438471': {'OKTMO': ['11708000001']},\n",
       " '438481': {'OKTMO': ['11701000001']},\n",
       " '438495': {'OKTMO': ['11701000001']},\n",
       " '438498': {'OKTMO': ['11708000001']},\n",
       " '438500': {'OKTMO': ['11701000001']},\n",
       " '438505': {'OKTMO': ['11701000']},\n",
       " '438509': {'OKTMO': ['11715000']},\n",
       " '438523': {'OKTMO': ['11701000001']},\n",
       " '438532': {'OKTMO': ['11701000001']},\n",
       " '438536': {'OKTMO': ['11730000001']},\n",
       " '438537': {'OKTMO': ['11701000001']},\n",
       " '438539': {'OKTMO': ['11715000']},\n",
       " '438540': {'OKTMO': ['11730000146']},\n",
       " '438541': {'OKTMO': ['11701000001']},\n",
       " '438552': {'OKTMO': ['11701000001']},\n",
       " '438558': {'OKTMO': ['11701000001']},\n",
       " '438559': {'OKTMO': ['11701000001']},\n",
       " '438569': {'OKTMO': ['11701000001']},\n",
       " '438574': {'OKTMO': ['11708000001']},\n",
       " '438575': {'OKTMO': ['11712000']},\n",
       " '438580': {'OKTMO': ['11701000001']},\n",
       " '438582': {'OKTMO': ['11708000001']},\n",
       " '438584': {'OKTMO': ['11730000001']},\n",
       " '438586': {'OKTMO': ['11708000001']},\n",
       " '438597': {'OKTMO': ['11701000001']},\n",
       " '438598': {'OKTMO': ['11701000001']},\n",
       " '438604': {'OKTMO': ['11701000001']},\n",
       " '438607': {'OKTMO': ['11701000001']},\n",
       " '438610': {'OKTMO': ['11708000001']},\n",
       " '438612': {'OKTMO': ['11730000116']},\n",
       " '438615': {'OKTMO': ['11708000001']},\n",
       " '438617': {'OKTMO': ['11708000001']},\n",
       " '438619': {'OKTMO': ['11725000001']},\n",
       " '438626': {'OKTMO': ['11708000001']},\n",
       " '438634': {'OKTMO': ['11701000001']},\n",
       " '438637': {'OKTMO': ['11730000001']},\n",
       " '438639': {'OKTMO': ['11715000']},\n",
       " '438641': {'OKTMO': ['11701000001']},\n",
       " '438651': {'OKTMO': ['11715000']},\n",
       " '438653': {'OKTMO': ['11701000001']},\n",
       " '438658': {'OKTMO': ['11708000001']},\n",
       " '438663': {'OKTMO': ['11708000001']},\n",
       " '438669': {'OKTMO': ['11701000001']},\n",
       " '438672': {'OKTMO': ['11708000001']},\n",
       " '438676': {'OKTMO': ['11715000']},\n",
       " '438677': {'OKTMO': ['11708000001']},\n",
       " '438679': {'OKTMO': ['11701000001']},\n",
       " '438682': {'OKTMO': ['11708000001']},\n",
       " '438691': {'OKTMO': ['11701000001']},\n",
       " '438693': {'OKTMO': ['11730000']},\n",
       " '438697': {'OKTMO': ['11708000001']},\n",
       " '438699': {'OKTMO': ['11715000']},\n",
       " '438707': {'OKTMO': ['11730000001']},\n",
       " '438708': {'OKTMO': ['11701000001']},\n",
       " '438711': {'OKTMO': ['11701000001']},\n",
       " '438715': {'OKTMO': ['11715000']},\n",
       " '438723': {'OKTMO': ['11708000001']},\n",
       " '438725': {'OKTMO': ['11708000001']},\n",
       " '438727': {'OKTMO': ['11730000126']},\n",
       " '438729': {'OKTMO': ['11701000001']},\n",
       " '438734': {'OKTMO': ['11730000001']},\n",
       " '438735': {'OKTMO': ['11701000001']},\n",
       " '438742': {'OKTMO': ['11701000001']},\n",
       " '438749': {'OKTMO': ['11701000001']},\n",
       " '438754': {'OKTMO': ['11715000001']},\n",
       " '438757': {'OKTMO': ['11730000']},\n",
       " '438758': {'OKTMO': ['11725000001']},\n",
       " '438761': {'OKTMO': ['11701000001']},\n",
       " '438772': {'OKTMO': ['11730000001']},\n",
       " '438777': {'OKTMO': ['11725000001']},\n",
       " '438780': {'OKTMO': ['11708000001']},\n",
       " '438782': {'OKTMO': ['11701000121']},\n",
       " '438784': {'OKTMO': ['11701000001']},\n",
       " '438788': {'OKTMO': ['11708000001']},\n",
       " '438790': {'OKTMO': ['11730000001']},\n",
       " '438792': {'OKTMO': ['11701000']},\n",
       " '438796': {'OKTMO': ['11701000001']},\n",
       " '438798': {'OKTMO': ['11701000001']},\n",
       " '438801': {'OKTMO': ['11701000001']},\n",
       " '438808': {'OKTMO': ['11701000']},\n",
       " '438817': {'OKTMO': ['11708000001']},\n",
       " '438820': {'OKTMO': ['11730000126']},\n",
       " '438824': {'OKTMO': ['11701000001']},\n",
       " '438827': {'OKTMO': ['11725000001']},\n",
       " '438828': {'OKTMO': ['11701000001']},\n",
       " '438829': {'OKTMO': ['11701000001']},\n",
       " '438830': {'OKTMO': ['11701000001']},\n",
       " '438833': {'OKTMO': ['11701000001']},\n",
       " '438834': {'OKTMO': ['11701000001']},\n",
       " '438840': {'OKTMO': ['11730000001']},\n",
       " '438843': {'OKTMO': ['11701000126']},\n",
       " '438849': {'OKTMO': ['11701000001']},\n",
       " '438855': {'OKTMO': ['11701000001']},\n",
       " '438858': {'OKTMO': ['11701000001']},\n",
       " '438867': {'OKTMO': ['11708000001']},\n",
       " '438869': {'OKTMO': ['11715000']},\n",
       " '438870': {'OKTMO': ['11701000001']},\n",
       " ...}"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "adobjp = adobjp[\n",
    "    (\n",
    "        adobjp['TYPEID'] == '7'\n",
    "    ) & (\n",
    "        adobjp['CHANGEIDEND'] == '0'\n",
    "    )\n",
    "]\n",
    "adobjp = adobjp[\n",
    "    adobjp.ENDDATE.apply(\n",
    "        lambda x: datetime.datetime.strptime(\n",
    "            x, '%Y-%m-%d'\n",
    "        ) > datetime.datetime.fromtimestamp(\n",
    "            time.time()\n",
    "        )\n",
    "    )\n",
    "]\n",
    "adobjp = adobjp[['OBJECTID', 'VALUE']].rename(\n",
    "    columns={'VALUE': 'OKTMO'}\n",
    ").drop_duplicates().groupby(\n",
    "    by='OBJECTID'\n",
    ").agg(\n",
    "    lambda x: x.to_list()\n",
    ").to_dict('index')\n",
    "adobjp"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Получаем дома"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>OBJECTID</th>\n",
       "      <th>OBJECTGUID</th>\n",
       "      <th>CHANGEID</th>\n",
       "      <th>HOUSENUM</th>\n",
       "      <th>HOUSETYPE</th>\n",
       "      <th>OPERTYPEID</th>\n",
       "      <th>PREVID</th>\n",
       "      <th>NEXTID</th>\n",
       "      <th>UPDATEDATE</th>\n",
       "      <th>STARTDATE</th>\n",
       "      <th>ENDDATE</th>\n",
       "      <th>ISACTUAL</th>\n",
       "      <th>ISACTIVE</th>\n",
       "      <th>HOUSENUM1</th>\n",
       "      <th>HOUSETYPE1</th>\n",
       "      <th>HOUSENUM2</th>\n",
       "      <th>HOUSETYPE2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>54479969</td>\n",
       "      <td>45196673</td>\n",
       "      <td>2bbf97d1-af74-4f19-bc66-cdf43835cb0e</td>\n",
       "      <td>68093520</td>\n",
       "      <td>39</td>\n",
       "      <td>2</td>\n",
       "      <td>20</td>\n",
       "      <td>26990714</td>\n",
       "      <td>0</td>\n",
       "      <td>2018-07-10</td>\n",
       "      <td>2018-07-10</td>\n",
       "      <td>2079-06-06</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>54535954</td>\n",
       "      <td>20364220</td>\n",
       "      <td>2c8b132e-2094-4870-88c2-6e644735548a</td>\n",
       "      <td>31881921</td>\n",
       "      <td>12</td>\n",
       "      <td>2</td>\n",
       "      <td>20</td>\n",
       "      <td>11881588</td>\n",
       "      <td>0</td>\n",
       "      <td>2017-04-04</td>\n",
       "      <td>2014-01-04</td>\n",
       "      <td>2079-06-06</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>54589521</td>\n",
       "      <td>14033232</td>\n",
       "      <td>2d4c885c-cdf0-4945-8951-cc3df80fbcb0</td>\n",
       "      <td>22472200</td>\n",
       "      <td>201</td>\n",
       "      <td>2</td>\n",
       "      <td>20</td>\n",
       "      <td>7772779</td>\n",
       "      <td>0</td>\n",
       "      <td>2018-07-10</td>\n",
       "      <td>2018-07-10</td>\n",
       "      <td>2079-06-06</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>14</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>54672508</td>\n",
       "      <td>21564216</td>\n",
       "      <td>2e77a52a-2ee8-4441-a756-2e8773a52a94</td>\n",
       "      <td>33676494</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>20</td>\n",
       "      <td>12668825</td>\n",
       "      <td>0</td>\n",
       "      <td>2019-05-30</td>\n",
       "      <td>2019-05-30</td>\n",
       "      <td>2079-06-06</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>54725164</td>\n",
       "      <td>54221186</td>\n",
       "      <td>2f359b37-8822-46b8-a400-7c51d0453345</td>\n",
       "      <td>81149068</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>20</td>\n",
       "      <td>32395831</td>\n",
       "      <td>0</td>\n",
       "      <td>2014-09-11</td>\n",
       "      <td>2014-01-10</td>\n",
       "      <td>2079-06-06</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         ID  OBJECTID                            OBJECTGUID  CHANGEID  \\\n",
       "0  54479969  45196673  2bbf97d1-af74-4f19-bc66-cdf43835cb0e  68093520   \n",
       "1  54535954  20364220  2c8b132e-2094-4870-88c2-6e644735548a  31881921   \n",
       "2  54589521  14033232  2d4c885c-cdf0-4945-8951-cc3df80fbcb0  22472200   \n",
       "3  54672508  21564216  2e77a52a-2ee8-4441-a756-2e8773a52a94  33676494   \n",
       "4  54725164  54221186  2f359b37-8822-46b8-a400-7c51d0453345  81149068   \n",
       "\n",
       "  HOUSENUM HOUSETYPE OPERTYPEID    PREVID NEXTID  UPDATEDATE   STARTDATE  \\\n",
       "0       39         2         20  26990714      0  2018-07-10  2018-07-10   \n",
       "1       12         2         20  11881588      0  2017-04-04  2014-01-04   \n",
       "2      201         2         20   7772779      0  2018-07-10  2018-07-10   \n",
       "3        6         2         20  12668825      0  2019-05-30  2019-05-30   \n",
       "4        2         2         20  32395831      0  2014-09-11  2014-01-10   \n",
       "\n",
       "      ENDDATE ISACTUAL ISACTIVE HOUSENUM1 HOUSETYPE1 HOUSENUM2 HOUSETYPE2  \n",
       "0  2079-06-06        1        1       NaN        NaN       NaN        NaN  \n",
       "1  2079-06-06        1        1       NaN        NaN       NaN        NaN  \n",
       "2  2079-06-06        1        1        14          2       NaN        NaN  \n",
       "3  2079-06-06        1        1       NaN        NaN       NaN        NaN  \n",
       "4  2079-06-06        1        1       NaN        NaN       NaN        NaN  "
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fname = glob.glob(os.path.join(region, 'AS_HOUSES_*.XML'))\n",
    "fname = [x for x in fname if 'PARAMS' not in x]\n",
    "if len(fname) != 1:\n",
    "    msg = f'Проверить количество файлов региона {region} там {len(fname)} файлов'\n",
    "    logger.error(msg)\n",
    "    raise Exception(msg)\n",
    "fname = fname[0]\n",
    "hous = parse_xml(fname)\n",
    "hous = hous.rename(\n",
    "    columns={\n",
    "        'ADDTYPE1': 'HOUSETYPE1',\n",
    "        'ADDTYPE2': 'HOUSETYPE2',\n",
    "        'ADDNUM1': 'HOUSENUM1',\n",
    "        'ADDNUM2': 'HOUSENUM2'\n",
    "    }\n",
    ")\n",
    "if 'ISACTUAL' in hous.columns:\n",
    "    hous = hous[(hous['ISACTUAL'] == '1') & (hous['ISACTIVE'] == '1')]\n",
    "else:\n",
    "    hous = hous[(hous['ISACTIVE'] == '1')]\n",
    "hous.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>HOUSETYPE</th>\n",
       "      <th>NAME</th>\n",
       "      <th>TYPENAME</th>\n",
       "      <th>TYPELONGNAME</th>\n",
       "      <th>ISACTIVE</th>\n",
       "      <th>UPDATEDATE</th>\n",
       "      <th>STARTDATE</th>\n",
       "      <th>ENDDATE</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>Владение</td>\n",
       "      <td>влд.</td>\n",
       "      <td>Владение</td>\n",
       "      <td>false</td>\n",
       "      <td>1900-01-01</td>\n",
       "      <td>1900-01-01</td>\n",
       "      <td>2015-11-05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>Дом</td>\n",
       "      <td>д.</td>\n",
       "      <td>Дом</td>\n",
       "      <td>true</td>\n",
       "      <td>1900-01-01</td>\n",
       "      <td>1900-01-01</td>\n",
       "      <td>2079-06-06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>Домовладение</td>\n",
       "      <td>двлд.</td>\n",
       "      <td>Домовладение</td>\n",
       "      <td>false</td>\n",
       "      <td>1900-01-01</td>\n",
       "      <td>1900-01-01</td>\n",
       "      <td>2015-11-05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>Гараж</td>\n",
       "      <td>г-ж</td>\n",
       "      <td>Гараж</td>\n",
       "      <td>true</td>\n",
       "      <td>1900-01-01</td>\n",
       "      <td>1900-01-01</td>\n",
       "      <td>2079-06-06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>Здание</td>\n",
       "      <td>зд.</td>\n",
       "      <td>Здание</td>\n",
       "      <td>true</td>\n",
       "      <td>1900-01-01</td>\n",
       "      <td>1900-01-01</td>\n",
       "      <td>2079-06-06</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  HOUSETYPE          NAME TYPENAME  TYPELONGNAME ISACTIVE  UPDATEDATE  \\\n",
       "0         1      Владение     влд.      Владение    false  1900-01-01   \n",
       "1         2           Дом       д.           Дом     true  1900-01-01   \n",
       "2         3  Домовладение    двлд.  Домовладение    false  1900-01-01   \n",
       "3         4         Гараж      г-ж         Гараж     true  1900-01-01   \n",
       "4         5        Здание      зд.        Здание     true  1900-01-01   \n",
       "\n",
       "    STARTDATE     ENDDATE  \n",
       "0  1900-01-01  2015-11-05  \n",
       "1  1900-01-01  2079-06-06  \n",
       "2  1900-01-01  2015-11-05  \n",
       "3  1900-01-01  2079-06-06  \n",
       "4  1900-01-01  2079-06-06  "
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fname = glob.glob('C:/Users/GlazkovOI/minzdrav/data/gar/AS_HOUSE_TYPES_*.XML')\n",
    "if len(fname) != 1:\n",
    "    msg = f'Проверить количество файлов региона {region} там {len(fname)} файлов'\n",
    "    logger.error(msg)\n",
    "    raise Exception(msg)\n",
    "fname = fname[0]\n",
    "houst = parse_xml(fname)\n",
    "houst = houst.rename(\n",
    "    columns={\n",
    "        'SHORTNAME': 'TYPENAME',\n",
    "        'DESC': 'TYPELONGNAME',\n",
    "        'ID': 'HOUSETYPE'\n",
    "    }\n",
    ")\n",
    "houst.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>HOUSETYPE</th>\n",
       "      <th>NAME</th>\n",
       "      <th>TYPENAME</th>\n",
       "      <th>TYPELONGNAME</th>\n",
       "      <th>ISACTIVE</th>\n",
       "      <th>UPDATEDATE</th>\n",
       "      <th>STARTDATE</th>\n",
       "      <th>ENDDATE</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>Корпус</td>\n",
       "      <td>к.</td>\n",
       "      <td>Корпус</td>\n",
       "      <td>true</td>\n",
       "      <td>2015-12-25</td>\n",
       "      <td>2015-12-25</td>\n",
       "      <td>2079-06-06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>Строение</td>\n",
       "      <td>стр.</td>\n",
       "      <td>Строение</td>\n",
       "      <td>true</td>\n",
       "      <td>2015-12-25</td>\n",
       "      <td>2015-12-25</td>\n",
       "      <td>2079-06-06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>Сооружение</td>\n",
       "      <td>соор.</td>\n",
       "      <td>Сооружение</td>\n",
       "      <td>true</td>\n",
       "      <td>2015-12-25</td>\n",
       "      <td>2015-12-25</td>\n",
       "      <td>2079-06-06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>Литера</td>\n",
       "      <td>литера</td>\n",
       "      <td>Литера</td>\n",
       "      <td>false</td>\n",
       "      <td>1900-01-01</td>\n",
       "      <td>1900-01-01</td>\n",
       "      <td>2015-12-25</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  HOUSETYPE        NAME TYPENAME TYPELONGNAME ISACTIVE  UPDATEDATE  \\\n",
       "0         1      Корпус       к.       Корпус     true  2015-12-25   \n",
       "1         2    Строение     стр.     Строение     true  2015-12-25   \n",
       "2         3  Сооружение    соор.   Сооружение     true  2015-12-25   \n",
       "3         4      Литера   литера       Литера    false  1900-01-01   \n",
       "\n",
       "    STARTDATE     ENDDATE  \n",
       "0  2015-12-25  2079-06-06  \n",
       "1  2015-12-25  2079-06-06  \n",
       "2  2015-12-25  2079-06-06  \n",
       "3  1900-01-01  2015-12-25  "
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fname = glob.glob('C:/Users/GlazkovOI/minzdrav/data/gar/AS_ADDHOUSE_TYPES_*.XML')\n",
    "if len(fname) != 1:\n",
    "    msg = f'Проверить количество файлов региона {region} там {len(fname)} файлов'\n",
    "    logger.error(msg)\n",
    "    raise Exception(msg)\n",
    "fname = fname[0]\n",
    "housta = parse_xml(fname)\n",
    "housta = housta.rename(\n",
    "    columns={\n",
    "        'SHORTNAME': 'TYPENAME',\n",
    "        'DESC': 'TYPELONGNAME',\n",
    "        'ID': 'HOUSETYPE'\n",
    "    }\n",
    ")\n",
    "housta.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>OBJECTID</th>\n",
       "      <th>OBJECTGUID</th>\n",
       "      <th>CHANGEID</th>\n",
       "      <th>HOUSENUM</th>\n",
       "      <th>HOUSETYPE</th>\n",
       "      <th>OPERTYPEID</th>\n",
       "      <th>PREVID</th>\n",
       "      <th>NEXTID</th>\n",
       "      <th>UPDATEDATE</th>\n",
       "      <th>...</th>\n",
       "      <th>HOUSENUM1</th>\n",
       "      <th>HOUSETYPE1</th>\n",
       "      <th>HOUSENUM2</th>\n",
       "      <th>HOUSETYPE2</th>\n",
       "      <th>TYPENAME</th>\n",
       "      <th>TYPELONGNAME</th>\n",
       "      <th>TYPENAME1</th>\n",
       "      <th>TYPELONGNAME1</th>\n",
       "      <th>TYPENAME2</th>\n",
       "      <th>TYPELONGNAME2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>54479969</td>\n",
       "      <td>45196673</td>\n",
       "      <td>2bbf97d1-af74-4f19-bc66-cdf43835cb0e</td>\n",
       "      <td>68093520</td>\n",
       "      <td>39</td>\n",
       "      <td>2</td>\n",
       "      <td>20</td>\n",
       "      <td>26990714</td>\n",
       "      <td>0</td>\n",
       "      <td>2018-07-10</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>д.</td>\n",
       "      <td>Дом</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>54535954</td>\n",
       "      <td>20364220</td>\n",
       "      <td>2c8b132e-2094-4870-88c2-6e644735548a</td>\n",
       "      <td>31881921</td>\n",
       "      <td>12</td>\n",
       "      <td>2</td>\n",
       "      <td>20</td>\n",
       "      <td>11881588</td>\n",
       "      <td>0</td>\n",
       "      <td>2017-04-04</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>д.</td>\n",
       "      <td>Дом</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>54589521</td>\n",
       "      <td>14033232</td>\n",
       "      <td>2d4c885c-cdf0-4945-8951-cc3df80fbcb0</td>\n",
       "      <td>22472200</td>\n",
       "      <td>201</td>\n",
       "      <td>2</td>\n",
       "      <td>20</td>\n",
       "      <td>7772779</td>\n",
       "      <td>0</td>\n",
       "      <td>2018-07-10</td>\n",
       "      <td>...</td>\n",
       "      <td>14</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>д.</td>\n",
       "      <td>Дом</td>\n",
       "      <td>стр.</td>\n",
       "      <td>Строение</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>54672508</td>\n",
       "      <td>21564216</td>\n",
       "      <td>2e77a52a-2ee8-4441-a756-2e8773a52a94</td>\n",
       "      <td>33676494</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>20</td>\n",
       "      <td>12668825</td>\n",
       "      <td>0</td>\n",
       "      <td>2019-05-30</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>д.</td>\n",
       "      <td>Дом</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>54725164</td>\n",
       "      <td>54221186</td>\n",
       "      <td>2f359b37-8822-46b8-a400-7c51d0453345</td>\n",
       "      <td>81149068</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>20</td>\n",
       "      <td>32395831</td>\n",
       "      <td>0</td>\n",
       "      <td>2014-09-11</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>д.</td>\n",
       "      <td>Дом</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 24 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         ID  OBJECTID                            OBJECTGUID  CHANGEID  \\\n",
       "0  54479969  45196673  2bbf97d1-af74-4f19-bc66-cdf43835cb0e  68093520   \n",
       "1  54535954  20364220  2c8b132e-2094-4870-88c2-6e644735548a  31881921   \n",
       "2  54589521  14033232  2d4c885c-cdf0-4945-8951-cc3df80fbcb0  22472200   \n",
       "3  54672508  21564216  2e77a52a-2ee8-4441-a756-2e8773a52a94  33676494   \n",
       "4  54725164  54221186  2f359b37-8822-46b8-a400-7c51d0453345  81149068   \n",
       "\n",
       "  HOUSENUM HOUSETYPE OPERTYPEID    PREVID NEXTID  UPDATEDATE  ... HOUSENUM1  \\\n",
       "0       39         2         20  26990714      0  2018-07-10  ...       NaN   \n",
       "1       12         2         20  11881588      0  2017-04-04  ...       NaN   \n",
       "2      201         2         20   7772779      0  2018-07-10  ...        14   \n",
       "3        6         2         20  12668825      0  2019-05-30  ...       NaN   \n",
       "4        2         2         20  32395831      0  2014-09-11  ...       NaN   \n",
       "\n",
       "  HOUSETYPE1 HOUSENUM2 HOUSETYPE2 TYPENAME TYPELONGNAME TYPENAME1  \\\n",
       "0        NaN       NaN        NaN       д.          Дом       NaN   \n",
       "1        NaN       NaN        NaN       д.          Дом       NaN   \n",
       "2          2       NaN        NaN       д.          Дом      стр.   \n",
       "3        NaN       NaN        NaN       д.          Дом       NaN   \n",
       "4        NaN       NaN        NaN       д.          Дом       NaN   \n",
       "\n",
       "  TYPELONGNAME1 TYPENAME2 TYPELONGNAME2  \n",
       "0           NaN       NaN           NaN  \n",
       "1           NaN       NaN           NaN  \n",
       "2      Строение       NaN           NaN  \n",
       "3           NaN       NaN           NaN  \n",
       "4           NaN       NaN           NaN  \n",
       "\n",
       "[5 rows x 24 columns]"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hous = hous.merge(\n",
    "    houst[[\n",
    "        'HOUSETYPE', 'TYPENAME', 'TYPELONGNAME'\n",
    "    ]].drop_duplicates(),\n",
    "    on='HOUSETYPE'\n",
    ")\n",
    "if 'HOUSETYPE1' in hous.columns:\n",
    "    hous = hous.merge(\n",
    "        housta[[\n",
    "            'HOUSETYPE', 'TYPENAME', 'TYPELONGNAME'\n",
    "        ]].rename(\n",
    "            columns={\n",
    "                'HOUSETYPE': 'HOUSETYPE1'\n",
    "            }\n",
    "        ).drop_duplicates(),\n",
    "        on='HOUSETYPE1',\n",
    "        how='left',\n",
    "        suffixes=(None, '1')\n",
    "    )\n",
    "else:\n",
    "    hous['HOUSETYPE1'] = np.nan\n",
    "    hous['TYPELONGNAME1'] = np.nan\n",
    "    hous['HOUSENUM1'] = np.nan\n",
    "    hous['TYPENAME1'] = np.nan\n",
    "if 'HOUSETYPE2' in hous.columns:\n",
    "    hous = hous.merge(\n",
    "        housta[[\n",
    "            'HOUSETYPE', 'TYPENAME', 'TYPELONGNAME'\n",
    "        ]].rename(\n",
    "            columns={\n",
    "                'HOUSETYPE': 'HOUSETYPE2'\n",
    "            }\n",
    "        ).drop_duplicates(),\n",
    "        on='HOUSETYPE2',\n",
    "        how='left',\n",
    "        suffixes=(None, '2')\n",
    "    )\n",
    "else:\n",
    "    hous['HOUSETYPE2'] = np.nan\n",
    "    hous['TYPELONGNAME2'] = np.nan\n",
    "    hous['HOUSENUM2'] = np.nan\n",
    "    hous['TYPENAME2'] = np.nan\n",
    "cleanup(houst)\n",
    "cleanup(housta)\n",
    "hous.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>OBJECTID</th>\n",
       "      <th>OBJECTGUID</th>\n",
       "      <th>CHANGEID</th>\n",
       "      <th>HOUSENUM</th>\n",
       "      <th>HOUSETYPE</th>\n",
       "      <th>OPERTYPEID</th>\n",
       "      <th>PREVID</th>\n",
       "      <th>NEXTID</th>\n",
       "      <th>UPDATEDATE</th>\n",
       "      <th>...</th>\n",
       "      <th>TYPELONGNAME</th>\n",
       "      <th>TYPENAME1</th>\n",
       "      <th>TYPELONGNAME1</th>\n",
       "      <th>TYPENAME2</th>\n",
       "      <th>TYPELONGNAME2</th>\n",
       "      <th>LEVEL</th>\n",
       "      <th>LEVELNAME</th>\n",
       "      <th>NAME</th>\n",
       "      <th>NAME1</th>\n",
       "      <th>NAME2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>54479969</td>\n",
       "      <td>45196673</td>\n",
       "      <td>2bbf97d1-af74-4f19-bc66-cdf43835cb0e</td>\n",
       "      <td>68093520</td>\n",
       "      <td>39</td>\n",
       "      <td>2</td>\n",
       "      <td>20</td>\n",
       "      <td>26990714</td>\n",
       "      <td>0</td>\n",
       "      <td>2018-07-10</td>\n",
       "      <td>...</td>\n",
       "      <td>Дом</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>10</td>\n",
       "      <td>Здание/Сооружение</td>\n",
       "      <td>дом 39</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>54535954</td>\n",
       "      <td>20364220</td>\n",
       "      <td>2c8b132e-2094-4870-88c2-6e644735548a</td>\n",
       "      <td>31881921</td>\n",
       "      <td>12</td>\n",
       "      <td>2</td>\n",
       "      <td>20</td>\n",
       "      <td>11881588</td>\n",
       "      <td>0</td>\n",
       "      <td>2017-04-04</td>\n",
       "      <td>...</td>\n",
       "      <td>Дом</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>10</td>\n",
       "      <td>Здание/Сооружение</td>\n",
       "      <td>дом 12</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>54589521</td>\n",
       "      <td>14033232</td>\n",
       "      <td>2d4c885c-cdf0-4945-8951-cc3df80fbcb0</td>\n",
       "      <td>22472200</td>\n",
       "      <td>201</td>\n",
       "      <td>2</td>\n",
       "      <td>20</td>\n",
       "      <td>7772779</td>\n",
       "      <td>0</td>\n",
       "      <td>2018-07-10</td>\n",
       "      <td>...</td>\n",
       "      <td>Дом</td>\n",
       "      <td>стр.</td>\n",
       "      <td>Строение</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>10</td>\n",
       "      <td>Здание/Сооружение</td>\n",
       "      <td>дом 201</td>\n",
       "      <td>строение 14</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>54672508</td>\n",
       "      <td>21564216</td>\n",
       "      <td>2e77a52a-2ee8-4441-a756-2e8773a52a94</td>\n",
       "      <td>33676494</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>20</td>\n",
       "      <td>12668825</td>\n",
       "      <td>0</td>\n",
       "      <td>2019-05-30</td>\n",
       "      <td>...</td>\n",
       "      <td>Дом</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>10</td>\n",
       "      <td>Здание/Сооружение</td>\n",
       "      <td>дом 6</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>54725164</td>\n",
       "      <td>54221186</td>\n",
       "      <td>2f359b37-8822-46b8-a400-7c51d0453345</td>\n",
       "      <td>81149068</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>20</td>\n",
       "      <td>32395831</td>\n",
       "      <td>0</td>\n",
       "      <td>2014-09-11</td>\n",
       "      <td>...</td>\n",
       "      <td>Дом</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>10</td>\n",
       "      <td>Здание/Сооружение</td>\n",
       "      <td>дом 2</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 29 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         ID  OBJECTID                            OBJECTGUID  CHANGEID  \\\n",
       "0  54479969  45196673  2bbf97d1-af74-4f19-bc66-cdf43835cb0e  68093520   \n",
       "1  54535954  20364220  2c8b132e-2094-4870-88c2-6e644735548a  31881921   \n",
       "2  54589521  14033232  2d4c885c-cdf0-4945-8951-cc3df80fbcb0  22472200   \n",
       "3  54672508  21564216  2e77a52a-2ee8-4441-a756-2e8773a52a94  33676494   \n",
       "4  54725164  54221186  2f359b37-8822-46b8-a400-7c51d0453345  81149068   \n",
       "\n",
       "  HOUSENUM HOUSETYPE OPERTYPEID    PREVID NEXTID  UPDATEDATE  ...  \\\n",
       "0       39         2         20  26990714      0  2018-07-10  ...   \n",
       "1       12         2         20  11881588      0  2017-04-04  ...   \n",
       "2      201         2         20   7772779      0  2018-07-10  ...   \n",
       "3        6         2         20  12668825      0  2019-05-30  ...   \n",
       "4        2         2         20  32395831      0  2014-09-11  ...   \n",
       "\n",
       "  TYPELONGNAME TYPENAME1 TYPELONGNAME1 TYPENAME2 TYPELONGNAME2 LEVEL  \\\n",
       "0          Дом       NaN           NaN       NaN           NaN    10   \n",
       "1          Дом       NaN           NaN       NaN           NaN    10   \n",
       "2          Дом      стр.      Строение       NaN           NaN    10   \n",
       "3          Дом       NaN           NaN       NaN           NaN    10   \n",
       "4          Дом       NaN           NaN       NaN           NaN    10   \n",
       "\n",
       "           LEVELNAME     NAME        NAME1 NAME2  \n",
       "0  Здание/Сооружение   дом 39                     \n",
       "1  Здание/Сооружение   дом 12                     \n",
       "2  Здание/Сооружение  дом 201  строение 14        \n",
       "3  Здание/Сооружение    дом 6                     \n",
       "4  Здание/Сооружение    дом 2                     \n",
       "\n",
       "[5 rows x 29 columns]"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hous['LEVEL'] = '10'\n",
    "hous['LEVELNAME'] = 'Здание/Сооружение'\n",
    "hous['NAME'] = hous[['TYPELONGNAME', 'HOUSENUM']].apply(\n",
    "    lambda x: (\n",
    "        x['TYPELONGNAME'].lower() + ' '\n",
    "        if x['TYPELONGNAME'] == x['TYPELONGNAME']\n",
    "        else ''\n",
    "    ) + x['HOUSENUM'],\n",
    "    axis=1\n",
    ")\n",
    "hous['NAME1'] = hous[['TYPELONGNAME1', 'HOUSENUM1']].apply(\n",
    "    lambda x: (\n",
    "        x['TYPELONGNAME1'].lower() + ' '\n",
    "        if x['TYPELONGNAME1'] == x['TYPELONGNAME1']\n",
    "        else ''\n",
    "    ) + (\n",
    "        x['HOUSENUM1']\n",
    "        if x['HOUSENUM1'] == x['HOUSENUM1']\n",
    "        else ''\n",
    "    ),\n",
    "    axis=1\n",
    ")\n",
    "hous['NAME2'] = hous[['TYPELONGNAME2', 'HOUSENUM2']].apply(\n",
    "    lambda x: (\n",
    "        x['TYPELONGNAME2'].lower() + ' '\n",
    "        if x['TYPELONGNAME2'] == x['TYPELONGNAME2']\n",
    "        else ''\n",
    "    ) + (\n",
    "        x['HOUSENUM2']\n",
    "        if x['HOUSENUM2'] == x['HOUSENUM2']\n",
    "        else ''\n",
    "    ),\n",
    "    axis=1\n",
    ")\n",
    "hous.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>OBJECTID</th>\n",
       "      <th>CHANGEID</th>\n",
       "      <th>CHANGEIDEND</th>\n",
       "      <th>TYPEID</th>\n",
       "      <th>VALUE</th>\n",
       "      <th>UPDATEDATE</th>\n",
       "      <th>STARTDATE</th>\n",
       "      <th>ENDDATE</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1442683843</td>\n",
       "      <td>160474178</td>\n",
       "      <td>547018951</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>11725000</td>\n",
       "      <td>2023-09-26</td>\n",
       "      <td>2023-09-26</td>\n",
       "      <td>2079-06-06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>347568713</td>\n",
       "      <td>61769180</td>\n",
       "      <td>92240712</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>11605442101</td>\n",
       "      <td>2017-12-17</td>\n",
       "      <td>2014-01-10</td>\n",
       "      <td>2079-06-06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>1476348075</td>\n",
       "      <td>160931043</td>\n",
       "      <td>571783275</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>11550000056</td>\n",
       "      <td>2023-10-31</td>\n",
       "      <td>2023-10-31</td>\n",
       "      <td>2079-06-06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>63</th>\n",
       "      <td>352449717</td>\n",
       "      <td>62659412</td>\n",
       "      <td>93538762</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>11605436101</td>\n",
       "      <td>2017-12-17</td>\n",
       "      <td>2014-01-10</td>\n",
       "      <td>2079-06-06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>102</th>\n",
       "      <td>354722053</td>\n",
       "      <td>63070135</td>\n",
       "      <td>94147379</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>11710000056</td>\n",
       "      <td>2019-08-20</td>\n",
       "      <td>2019-08-20</td>\n",
       "      <td>2079-06-06</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             ID   OBJECTID   CHANGEID CHANGEIDEND TYPEID        VALUE  \\\n",
       "1    1442683843  160474178  547018951           0      7     11725000   \n",
       "26    347568713   61769180   92240712           0      7  11605442101   \n",
       "41   1476348075  160931043  571783275           0      7  11550000056   \n",
       "63    352449717   62659412   93538762           0      7  11605436101   \n",
       "102   354722053   63070135   94147379           0      7  11710000056   \n",
       "\n",
       "     UPDATEDATE   STARTDATE     ENDDATE  \n",
       "1    2023-09-26  2023-09-26  2079-06-06  \n",
       "26   2017-12-17  2014-01-10  2079-06-06  \n",
       "41   2023-10-31  2023-10-31  2079-06-06  \n",
       "63   2017-12-17  2014-01-10  2079-06-06  \n",
       "102  2019-08-20  2019-08-20  2079-06-06  "
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fname = glob.glob(os.path.join(region, 'AS_HOUSES_PARAMS_*.XML'))\n",
    "fname = fname[0]\n",
    "hp = parse_xml(fname)\n",
    "hp = hp[\n",
    "    (\n",
    "        hp['TYPEID'] == '7'\n",
    "    ) & (\n",
    "        hp['CHANGEIDEND'] == '0'\n",
    "    )\n",
    "]\n",
    "hp = hp[\n",
    "    hp.ENDDATE.apply(\n",
    "        lambda x: datetime.datetime.strptime(\n",
    "            x, '%Y-%m-%d'\n",
    "        ) > datetime.datetime.fromtimestamp(\n",
    "            time.time()\n",
    "        )\n",
    "    )\n",
    "]\n",
    "hp.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'100003608': {'OKTMO': ['11527000416']},\n",
       " '100003646': {'OKTMO': ['11527000152']},\n",
       " '100004593': {'OKTMO': ['11527000120']},\n",
       " '100018383': {'OKTMO': ['11548000204']},\n",
       " '100028253': {'OKTMO': ['11552000286']},\n",
       " '100033574': {'OKTMO': ['11622151111']},\n",
       " '100033712': {'OKTMO': ['11622151106']},\n",
       " '100033842': {'OKTMO': ['11622151106']},\n",
       " '10003924': {'OKTMO': ['11701000001']},\n",
       " '10004768': {'OKTMO': ['11701000001']},\n",
       " '100047859': {'OKTMO': ['11605448221']},\n",
       " '100047876': {'OKTMO': ['11605157051']},\n",
       " '100047880': {'OKTMO': ['11605157051']},\n",
       " '100047894': {'OKTMO': ['11646432111']},\n",
       " '10004862': {'OKTMO': ['11701000001']},\n",
       " '100050584': {'OKTMO': ['11654456181']},\n",
       " '10005199': {'OKTMO': ['11701000001']},\n",
       " '100057842': {'OKTMO': ['11622151051']},\n",
       " '100059308': {'OKTMO': ['11552000']},\n",
       " '100059509': {'OKTMO': ['11622151051']},\n",
       " '100059510': {'OKTMO': ['11622151051']},\n",
       " '100059511': {'OKTMO': ['11622151051']},\n",
       " '100059512': {'OKTMO': ['11622151051']},\n",
       " '100059513': {'OKTMO': ['11622151051']},\n",
       " '100059526': {'OKTMO': ['11548000204']},\n",
       " '100060226': {'OKTMO': ['11622151051']},\n",
       " '100060379': {'OKTMO': ['11622151051']},\n",
       " '100060380': {'OKTMO': ['11622151051']},\n",
       " '100060381': {'OKTMO': ['11622151051']},\n",
       " '100060382': {'OKTMO': ['11622151051']},\n",
       " '100060429': {'OKTMO': ['11622151051']},\n",
       " '100060613': {'OKTMO': ['11622151051']},\n",
       " '100060629': {'OKTMO': ['11622151051']},\n",
       " '100060699': {'OKTMO': ['11622151051']},\n",
       " '100066649': {'OKTMO': ['11635157051']},\n",
       " '100066652': {'OKTMO': ['11635157051']},\n",
       " '100066665': {'OKTMO': ['11646432101']},\n",
       " '10006688': {'OKTMO': ['11605446101']},\n",
       " '100068755': {'OKTMO': ['11544000306']},\n",
       " '100068954': {'OKTMO': ['11552000']},\n",
       " '10006975': {'OKTMO': ['11605446101']},\n",
       " '100073299': {'OKTMO': ['11527000410']},\n",
       " '10007333': {'OKTMO': ['11605446101']},\n",
       " '100073418': {'OKTMO': ['11527000698']},\n",
       " '100073426': {'OKTMO': ['11710000001']},\n",
       " '100073576': {'OKTMO': ['11622151051']},\n",
       " '100073577': {'OKTMO': ['11622151051']},\n",
       " '100075557': {'OKTMO': ['11552000']},\n",
       " '100075574': {'OKTMO': ['11552000284']},\n",
       " '100075580': {'OKTMO': ['11552000284']},\n",
       " '100075582': {'OKTMO': ['11552000284']},\n",
       " '100075584': {'OKTMO': ['11552000284']},\n",
       " '100075617': {'OKTMO': ['11552000284']},\n",
       " '100075620': {'OKTMO': ['11552000']},\n",
       " '100076884': {'OKTMO': ['11622151051']},\n",
       " '100076970': {'OKTMO': ['11622151051']},\n",
       " '100076971': {'OKTMO': ['11622151051']},\n",
       " '100076972': {'OKTMO': ['11622151051']},\n",
       " '100076973': {'OKTMO': ['11622151051']},\n",
       " '100077839': {'OKTMO': ['11622151051']},\n",
       " '100077840': {'OKTMO': ['11622151051']},\n",
       " '100077849': {'OKTMO': ['11527000152']},\n",
       " '100077853': {'OKTMO': ['11622151051']},\n",
       " '100077855': {'OKTMO': ['11622151051']},\n",
       " '100077917': {'OKTMO': ['11622151051']},\n",
       " '10007994': {'OKTMO': ['11605446101']},\n",
       " '10008033': {'OKTMO': ['11605446101']},\n",
       " '100080881': {'OKTMO': ['11622151051']},\n",
       " '100080882': {'OKTMO': ['11622151051']},\n",
       " '100080883': {'OKTMO': ['11622151051']},\n",
       " '100082381': {'OKTMO': ['11622151051']},\n",
       " '100082383': {'OKTMO': ['11622151051']},\n",
       " '100082399': {'OKTMO': ['11622151051']},\n",
       " '100082400': {'OKTMO': ['11622151051']},\n",
       " '100082401': {'OKTMO': ['11622151051']},\n",
       " '10008896': {'OKTMO': ['11605446101']},\n",
       " '100094212': {'OKTMO': ['11708000001']},\n",
       " '100095619': {'OKTMO': ['11622151051']},\n",
       " '100095636': {'OKTMO': ['11622151051']},\n",
       " '100095819': {'OKTMO': ['11622151051']},\n",
       " '100095871': {'OKTMO': ['11622151051']},\n",
       " '100100252': {'OKTMO': ['11622151051']},\n",
       " '100100255': {'OKTMO': ['11622151051']},\n",
       " '100100257': {'OKTMO': ['11622151051']},\n",
       " '100100259': {'OKTMO': ['11622151051']},\n",
       " '100101765': {'OKTMO': ['11622151051']},\n",
       " '100101850': {'OKTMO': ['11622151051']},\n",
       " '100101886': {'OKTMO': ['11622151051']},\n",
       " '100103434': {'OKTMO': ['11622151051']},\n",
       " '100103436': {'OKTMO': ['11605418101']},\n",
       " '100103441': {'OKTMO': ['11622151051']},\n",
       " '100103502': {'OKTMO': ['11622151051']},\n",
       " '100103503': {'OKTMO': ['11622151051']},\n",
       " '100103666': {'OKTMO': ['11622151051']},\n",
       " '100105791': {'OKTMO': ['11556000913']},\n",
       " '100106349': {'OKTMO': ['11622151106']},\n",
       " '100106350': {'OKTMO': ['11622151106']},\n",
       " '100106369': {'OKTMO': ['11622151106']},\n",
       " '100106377': {'OKTMO': ['11605101001']},\n",
       " '100110036': {'OKTMO': ['11622151111']},\n",
       " '100110132': {'OKTMO': ['11622151111']},\n",
       " '100110133': {'OKTMO': ['11622151111']},\n",
       " '100110458': {'OKTMO': ['11514000296']},\n",
       " '100121793': {'OKTMO': ['11646402101']},\n",
       " '100123249': {'OKTMO': ['11708000001']},\n",
       " '10012502': {'OKTMO': ['11558000640']},\n",
       " '10012679': {'OKTMO': ['11558000640']},\n",
       " '10013470': {'OKTMO': ['11558000640']},\n",
       " '100136630': {'OKTMO': ['11635157051']},\n",
       " '100139254': {'OKTMO': ['11527000057']},\n",
       " '100140240': {'OKTMO': ['11715000']},\n",
       " '10014044': {'OKTMO': ['11558000640']},\n",
       " '10014539': {'OKTMO': ['11558000640']},\n",
       " '100147936': {'OKTMO': ['11558000001']},\n",
       " '100148975': {'OKTMO': ['11527000057']},\n",
       " '10014946': {'OKTMO': ['11558000640']},\n",
       " '100153436': {'OKTMO': ['11552000']},\n",
       " '100154862': {'OKTMO': ['11550000661']},\n",
       " '100156381': {'OKTMO': ['11514000101']},\n",
       " '100156686': {'OKTMO': ['11552000271']},\n",
       " '100158167': {'OKTMO': ['11552000134']},\n",
       " '100170551': {'OKTMO': ['11701000001']},\n",
       " '100171671': {'OKTMO': ['11605101001']},\n",
       " '100171691': {'OKTMO': ['11605101001']},\n",
       " '100172698': {'OKTMO': ['11605448221']},\n",
       " '100174488': {'OKTMO': ['11701000001']},\n",
       " '100174623': {'OKTMO': ['11530000393']},\n",
       " '100175254': {'OKTMO': ['11708000001']},\n",
       " '100178892': {'OKTMO': ['11550000613']},\n",
       " '100179119': {'OKTMO': ['11635157051']},\n",
       " '100188241': {'OKTMO': ['11605402121']},\n",
       " '10018835': {'OKTMO': ['11558000640']},\n",
       " '100188393': {'OKTMO': ['11715000001']},\n",
       " '100195081': {'OKTMO': ['11514000101']},\n",
       " '100195782': {'OKTMO': ['11558000']},\n",
       " '100200081': {'OKTMO': ['11558000205']},\n",
       " '100201277': {'OKTMO': ['11730000146']},\n",
       " '100203199': {'OKTMO': ['11708000001']},\n",
       " '10020445': {'OKTMO': ['11558000640']},\n",
       " '100205711': {'OKTMO': ['11554000181']},\n",
       " '10020614': {'OKTMO': ['11558000640']},\n",
       " '10021050': {'OKTMO': ['11558000640']},\n",
       " '100211141': {'OKTMO': ['11605428106']},\n",
       " '100212381': {'OKTMO': ['11605101001']},\n",
       " '100212382': {'OKTMO': ['11605101001']},\n",
       " '100212520': {'OKTMO': ['11514000101']},\n",
       " '100213707': {'OKTMO': ['11558000244']},\n",
       " '100214017': {'OKTMO': ['11605428106']},\n",
       " '100214541': {'OKTMO': ['11558000727']},\n",
       " '100214542': {'OKTMO': ['11558000727']},\n",
       " '100214543': {'OKTMO': ['11558000727']},\n",
       " '100214544': {'OKTMO': ['11558000727']},\n",
       " '100214545': {'OKTMO': ['11558000727']},\n",
       " '100214546': {'OKTMO': ['11558000727']},\n",
       " '10021758': {'OKTMO': ['11558000640']},\n",
       " '100219714': {'OKTMO': ['11550000799']},\n",
       " '100220257': {'OKTMO': ['11552000295']},\n",
       " '100220385': {'OKTMO': ['11552000']},\n",
       " '100225495': {'OKTMO': ['11508000797']},\n",
       " '100225996': {'OKTMO': ['11552000295']},\n",
       " '10022627': {'OKTMO': ['11605412111']},\n",
       " '100226551': {'OKTMO': ['11605418136']},\n",
       " '10022780': {'OKTMO': ['11558000640']},\n",
       " '100228330': {'OKTMO': ['11552000']},\n",
       " '100231736': {'OKTMO': ['11605442101']},\n",
       " '100232280': {'OKTMO': ['11514000101']},\n",
       " '100232347': {'OKTMO': ['11605101001']},\n",
       " '100232480': {'OKTMO': ['11514000101']},\n",
       " '100232519': {'OKTMO': ['11514000101']},\n",
       " '100232534': {'OKTMO': ['11514000101']},\n",
       " '100233221': {'OKTMO': ['11552000279']},\n",
       " '100233694': {'OKTMO': ['11527000396']},\n",
       " '100234193': {'OKTMO': ['11514000101']},\n",
       " '100235913': {'OKTMO': ['11552000']},\n",
       " '100236093': {'OKTMO': ['11605101111']},\n",
       " '100236356': {'OKTMO': ['11552000237']},\n",
       " '10024131': {'OKTMO': ['11558000640']},\n",
       " '100241315': {'OKTMO': ['11552000255']},\n",
       " '100241316': {'OKTMO': ['11552000118']},\n",
       " '100244166': {'OKTMO': ['11605418136']},\n",
       " '100245572': {'OKTMO': ['11552000232']},\n",
       " '100245611': {'OKTMO': ['11552000295']},\n",
       " '100246719': {'OKTMO': ['11710000001']},\n",
       " '100246722': {'OKTMO': ['11710000001']},\n",
       " '100246735': {'OKTMO': ['11710000001']},\n",
       " '100246744': {'OKTMO': ['11710000001']},\n",
       " '100251650': {'OKTMO': ['11552000243']},\n",
       " '100255235': {'OKTMO': ['11556000729']},\n",
       " '10025679': {'OKTMO': ['11558000640']},\n",
       " '100257680': {'OKTMO': ['11730000']},\n",
       " '100257966': {'OKTMO': ['11730000']},\n",
       " '100258037': {'OKTMO': ['11730000']},\n",
       " '100258118': {'OKTMO': ['11730000']},\n",
       " '100259211': {'OKTMO': ['11508000587']},\n",
       " '100259262': {'OKTMO': ['11730000001']},\n",
       " '100259303': {'OKTMO': ['11646416106']},\n",
       " '100259304': {'OKTMO': ['11646416106']},\n",
       " '100259310': {'OKTMO': ['11730000']},\n",
       " '100261563': {'OKTMO': ['11550000640']},\n",
       " '10026302': {'OKTMO': ['11558000640']},\n",
       " '100268252': {'OKTMO': ['11635420101']},\n",
       " '10026889': {'OKTMO': ['11558000640']},\n",
       " '100269561': {'OKTMO': ['11730000126']},\n",
       " '100270215': {'OKTMO': ['11605157051']},\n",
       " '10027524': {'OKTMO': ['11558000640']},\n",
       " '10028318': {'OKTMO': ['11656428126']},\n",
       " '100285515': {'OKTMO': ['11605101001']},\n",
       " '100285676': {'OKTMO': ['11646432101']},\n",
       " '100285699': {'OKTMO': ['11710000001']},\n",
       " '100285700': {'OKTMO': ['11710000001']},\n",
       " '100285701': {'OKTMO': ['11710000001']},\n",
       " '10028836': {'OKTMO': ['11646432121']},\n",
       " '100288486': {'OKTMO': ['11605420101']},\n",
       " '100289380': {'OKTMO': ['11508000704']},\n",
       " '100289608': {'OKTMO': ['11550000051']},\n",
       " '100290584': {'OKTMO': ['11544000551']},\n",
       " '10029086': {'OKTMO': ['11656428126']},\n",
       " '100297428': {'OKTMO': ['11527000640']},\n",
       " '100297801': {'OKTMO': ['11527000448']},\n",
       " '100298292': {'OKTMO': ['11552000']},\n",
       " '10030166': {'OKTMO': ['11646432121']},\n",
       " '100302143': {'OKTMO': ['11552000']},\n",
       " '100306065': {'OKTMO': ['11605449101']},\n",
       " '100306214': {'OKTMO': ['11558000430']},\n",
       " '100308217': {'OKTMO': ['11710000001']},\n",
       " '100308233': {'OKTMO': ['11710000001']},\n",
       " '100309334': {'OKTMO': ['11556000483']},\n",
       " '10030959': {'OKTMO': ['11646432121']},\n",
       " '100309697': {'OKTMO': ['11556000101']},\n",
       " '10031410': {'OKTMO': ['11556000871']},\n",
       " '10031658': {'OKTMO': ['11646432121']},\n",
       " '100316777': {'OKTMO': ['11646432101']},\n",
       " '100316778': {'OKTMO': ['11646432121']},\n",
       " '100317829': {'OKTMO': ['11552000183']},\n",
       " '100320194': {'OKTMO': ['11554000']},\n",
       " '10032102': {'OKTMO': ['11646432121']},\n",
       " '100322086': {'OKTMO': ['11552000']},\n",
       " '100322260': {'OKTMO': ['11554000505']},\n",
       " '10032272': {'OKTMO': ['11558000640']},\n",
       " '100327281': {'OKTMO': ['11544000866']},\n",
       " '10033041': {'OKTMO': ['11730000001']},\n",
       " '100332428': {'OKTMO': ['11556000101']},\n",
       " '10033313': {'OKTMO': ['11656428126']},\n",
       " '100333186': {'OKTMO': ['11514000101']},\n",
       " '100333202': {'OKTMO': ['11554000709']},\n",
       " '100333207': {'OKTMO': ['11508000941']},\n",
       " '100333252': {'OKTMO': ['11646432101']},\n",
       " '100333646': {'OKTMO': ['11635157111']},\n",
       " '10033376': {'OKTMO': ['11558000640']},\n",
       " '100334380': {'OKTMO': ['11552000116']},\n",
       " '100334451': {'OKTMO': ['11552000217']},\n",
       " '10033574': {'OKTMO': ['11646432121']},\n",
       " '100335801': {'OKTMO': ['11552000']},\n",
       " '10033584': {'OKTMO': ['11730000001']},\n",
       " '100336371': {'OKTMO': ['11558000859']},\n",
       " '100336377': {'OKTMO': ['11558000859']},\n",
       " '10033741': {'OKTMO': ['11646432121']},\n",
       " '10034024': {'OKTMO': ['11656428126']},\n",
       " '100340289': {'OKTMO': ['11730000']},\n",
       " '100340903': {'OKTMO': ['11730000']},\n",
       " '100341615': {'OKTMO': ['11622406101']},\n",
       " '100341702': {'OKTMO': ['11730000001']},\n",
       " '100342038': {'OKTMO': ['11730000']},\n",
       " '10034206': {'OKTMO': ['11556000871']},\n",
       " '10034209': {'OKTMO': ['11646432121']},\n",
       " '100342432': {'OKTMO': ['11622151111']},\n",
       " '100343059': {'OKTMO': ['11730000']},\n",
       " '10034341': {'OKTMO': ['11605446101']},\n",
       " '10034551': {'OKTMO': ['11605446101']},\n",
       " '10035086': {'OKTMO': ['11605446101']},\n",
       " '100352721': {'OKTMO': ['11554000751']},\n",
       " '100354628': {'OKTMO': ['11508000881']},\n",
       " '10035619': {'OKTMO': ['11558000640']},\n",
       " '100356487': {'OKTMO': ['11514000576']},\n",
       " '100356509': {'OKTMO': ['11514000576']},\n",
       " '10035874': {'OKTMO': ['11605446101']},\n",
       " '10035948': {'OKTMO': ['11730000001']},\n",
       " '100366384': {'OKTMO': ['11554000']},\n",
       " '100366396': {'OKTMO': ['11554000']},\n",
       " '100366600': {'OKTMO': ['11552000279']},\n",
       " '10037191': {'OKTMO': ['11605446101']},\n",
       " '10037331': {'OKTMO': ['11558000640']},\n",
       " '10037420': {'OKTMO': ['11558000640']},\n",
       " '10037432': {'OKTMO': ['11605446101']},\n",
       " '10037634': {'OKTMO': ['11558000640']},\n",
       " '100379793': {'OKTMO': ['11710000001']},\n",
       " '100379883': {'OKTMO': ['11622151106']},\n",
       " '100379970': {'OKTMO': ['11554000051']},\n",
       " '100380110': {'OKTMO': ['11622151051']},\n",
       " '100380111': {'OKTMO': ['11622151051']},\n",
       " '100380214': {'OKTMO': ['11635157051']},\n",
       " '100380226': {'OKTMO': ['11622151051']},\n",
       " '100382120': {'OKTMO': ['11514000481']},\n",
       " '100382585': {'OKTMO': ['11701000001']},\n",
       " '100382809': {'OKTMO': ['11701000001']},\n",
       " '10038918': {'OKTMO': ['11605446101']},\n",
       " '10038937': {'OKTMO': ['11558000640']},\n",
       " '100390075': {'OKTMO': ['11552000134']},\n",
       " '100390115': {'OKTMO': ['11550000769']},\n",
       " '10039199': {'OKTMO': ['11605446101']},\n",
       " '100392096': {'OKTMO': ['11550000769']},\n",
       " '100392163': {'OKTMO': ['11542000001']},\n",
       " '100392242': {'OKTMO': ['11544000306']},\n",
       " '100393940': {'OKTMO': ['11544000826']},\n",
       " '10039655': {'OKTMO': ['11558000640']},\n",
       " '10039773': {'OKTMO': ['11558000640']},\n",
       " '10039792': {'OKTMO': ['11605446101']},\n",
       " '100399002': {'OKTMO': ['11550000056']},\n",
       " '100399684': {'OKTMO': ['11605101001']},\n",
       " '10039987': {'OKTMO': ['11558000640']},\n",
       " '10040025': {'OKTMO': ['11514000531']},\n",
       " '10040146': {'OKTMO': ['11605446101']},\n",
       " '10040273': {'OKTMO': ['11605446101']},\n",
       " '10040448': {'OKTMO': ['11605446101']},\n",
       " '100405834': {'OKTMO': ['11544000001']},\n",
       " '100408210': {'OKTMO': ['11622151051']},\n",
       " '100408214': {'OKTMO': ['11710000001']},\n",
       " '100408222': {'OKTMO': ['11622151051']},\n",
       " '10040886': {'OKTMO': ['11605446101']},\n",
       " '10040908': {'OKTMO': ['11558000640']},\n",
       " '100410153': {'OKTMO': ['11701000001']},\n",
       " '10041781': {'OKTMO': ['11558000640']},\n",
       " '10041809': {'OKTMO': ['11514000531']},\n",
       " '10042186': {'OKTMO': ['11514000531']},\n",
       " '100423145': {'OKTMO': ['11552000116']},\n",
       " '100423155': {'OKTMO': ['11552000297']},\n",
       " '100423214': {'OKTMO': ['11708000001']},\n",
       " '100423254': {'OKTMO': ['11708000001']},\n",
       " '100425463': {'OKTMO': ['11708000001']},\n",
       " '100427080': {'OKTMO': ['11556000729']},\n",
       " '100428138': {'OKTMO': ['11544000']},\n",
       " '100428175': {'OKTMO': ['11544000']},\n",
       " '10043189': {'OKTMO': ['11514000531']},\n",
       " '100435291': {'OKTMO': ['11527000354']},\n",
       " '10043737': {'OKTMO': ['11605446101']},\n",
       " '100438610': {'OKTMO': ['11552000286']},\n",
       " '100438613': {'OKTMO': ['11552000286']},\n",
       " '100439998': {'OKTMO': ['11556000719']},\n",
       " '100441073': {'OKTMO': ['11508000920']},\n",
       " '100441075': {'OKTMO': ['11552000']},\n",
       " '10044196': {'OKTMO': ['11605446101']},\n",
       " '10044366': {'OKTMO': ['11558000640']},\n",
       " '10044389': {'OKTMO': ['11605446101']},\n",
       " '10044638': {'OKTMO': ['11558000640']},\n",
       " '10044812': {'OKTMO': ['11646416121']},\n",
       " '10044880': {'OKTMO': ['11558000640']},\n",
       " '10044953': {'OKTMO': ['11605446101']},\n",
       " '10045213': {'OKTMO': ['11558000640']},\n",
       " '10045222': {'OKTMO': ['11646416121']},\n",
       " '10045462': {'OKTMO': ['11605446101']},\n",
       " '10045510': {'OKTMO': ['11646416121']},\n",
       " '10045726': {'OKTMO': ['11514000531']},\n",
       " '100461632': {'OKTMO': ['11552000286']},\n",
       " '100462668': {'OKTMO': ['11605157051']},\n",
       " '10046331': {'OKTMO': ['11514000531']},\n",
       " '10046345': {'OKTMO': ['11646416121']},\n",
       " '10046347': {'OKTMO': ['11558000640']},\n",
       " '100463648': {'OKTMO': ['11708000001']},\n",
       " '100465262': {'OKTMO': ['11605157051']},\n",
       " '10046873': {'OKTMO': ['11514000531']},\n",
       " '10046918': {'OKTMO': ['11544000801']},\n",
       " '100470010': {'OKTMO': ['11542000341']},\n",
       " '100470011': {'OKTMO': ['11554000439']},\n",
       " '100470639': {'OKTMO': ['11605101001']},\n",
       " '10047133': {'OKTMO': ['11544000801']},\n",
       " '10047227': {'OKTMO': ['11558000640']},\n",
       " '10047461': {'OKTMO': ['11514000531']},\n",
       " '100475881': {'OKTMO': ['11730000126']},\n",
       " '100475883': {'OKTMO': ['11730000126']},\n",
       " '100475885': {'OKTMO': ['11730000126']},\n",
       " '100476129': {'OKTMO': ['11701000001']},\n",
       " '10047633': {'OKTMO': ['11544000801']},\n",
       " '100476396': {'OKTMO': ['11542000301']},\n",
       " '100478261': {'OKTMO': ['11552000']},\n",
       " '10047922': {'OKTMO': ['11558000640']},\n",
       " '100480091': {'OKTMO': ['11622418101']},\n",
       " '10048421': {'OKTMO': ['11514000531']},\n",
       " '10048428': {'OKTMO': ['11544000801']},\n",
       " '10048554': {'OKTMO': ['11558000640']},\n",
       " '10048653': {'OKTMO': ['11544000801']},\n",
       " '100490639': {'OKTMO': ['11552000148']},\n",
       " '100490645': {'OKTMO': ['11552000216']},\n",
       " '100492054': {'OKTMO': ['11605157051']},\n",
       " '100492281': {'OKTMO': ['11527000052']},\n",
       " '100492946': {'OKTMO': ['11605157051']},\n",
       " '100492989': {'OKTMO': ['11552000146']},\n",
       " '10049308': {'OKTMO': ['11558000640']},\n",
       " '10049508': {'OKTMO': ['11514000531']},\n",
       " '10049816': {'OKTMO': ['11558000640']},\n",
       " '10049928': {'OKTMO': ['11605420101']},\n",
       " '10050201': {'OKTMO': ['11558000640']},\n",
       " '10050237': {'OKTMO': ['11558000640']},\n",
       " '10050326': {'OKTMO': ['11605420101']},\n",
       " '100503679': {'OKTMO': ['11550000799']},\n",
       " '10050390': {'OKTMO': ['11514000531']},\n",
       " '10050664': {'OKTMO': ['11558000640']},\n",
       " '10050785': {'OKTMO': ['11514000531']},\n",
       " '10052153': {'OKTMO': ['11558000640']},\n",
       " '100527018': {'OKTMO': ['11527000057']},\n",
       " '100527655': {'OKTMO': ['11548000208']},\n",
       " '100527915': {'OKTMO': ['11708000001']},\n",
       " '100528251': {'OKTMO': ['11605402101']},\n",
       " '10053033': {'OKTMO': ['11558000640']},\n",
       " '100531215': {'OKTMO': ['11605402111']},\n",
       " '100532176': {'OKTMO': ['11552000279']},\n",
       " '100533828': {'OKTMO': ['11548000101']},\n",
       " '10053655': {'OKTMO': ['11558000640']},\n",
       " '100540275': {'OKTMO': ['11542000291']},\n",
       " '100542053': {'OKTMO': ['11556000755']},\n",
       " '100543278': {'OKTMO': ['11710000001']},\n",
       " '100543283': {'OKTMO': ['11710000056']},\n",
       " '10054337': {'OKTMO': ['11558000640']},\n",
       " '100546018': {'OKTMO': ['11552000279']},\n",
       " '100547253': {'OKTMO': ['11550000051']},\n",
       " '10054761': {'OKTMO': ['11558000640']},\n",
       " '100551095': {'OKTMO': ['11530000101']},\n",
       " '10055154': {'OKTMO': ['11558000640']},\n",
       " '10055867': {'OKTMO': ['11558000640']},\n",
       " '100561406': {'OKTMO': ['11552000267']},\n",
       " '100561695': {'OKTMO': ['11552000']},\n",
       " '100561696': {'OKTMO': ['11552000']},\n",
       " '100561697': {'OKTMO': ['11552000']},\n",
       " '100561698': {'OKTMO': ['11552000']},\n",
       " '100561699': {'OKTMO': ['11552000']},\n",
       " '100561700': {'OKTMO': ['11552000']},\n",
       " '100561705': {'OKTMO': ['11554000181']},\n",
       " '10056485': {'OKTMO': ['11558000640']},\n",
       " '10056502': {'OKTMO': ['11730000001']},\n",
       " '100569257': {'OKTMO': ['11552000']},\n",
       " '100569258': {'OKTMO': ['11552000']},\n",
       " '100569259': {'OKTMO': ['11552000']},\n",
       " '100569260': {'OKTMO': ['11552000']},\n",
       " '100569261': {'OKTMO': ['11552000']},\n",
       " '100569262': {'OKTMO': ['11552000']},\n",
       " '100569263': {'OKTMO': ['11552000']},\n",
       " '100569264': {'OKTMO': ['11552000']},\n",
       " '100569265': {'OKTMO': ['11552000']},\n",
       " '100569266': {'OKTMO': ['11552000']},\n",
       " '100569267': {'OKTMO': ['11552000']},\n",
       " '100569283': {'OKTMO': ['11552000']},\n",
       " '100569284': {'OKTMO': ['11552000']},\n",
       " '100569285': {'OKTMO': ['11552000']},\n",
       " '100569286': {'OKTMO': ['11552000']},\n",
       " '100569287': {'OKTMO': ['11552000']},\n",
       " '100569288': {'OKTMO': ['11552000']},\n",
       " '100569289': {'OKTMO': ['11552000']},\n",
       " '100569290': {'OKTMO': ['11552000']},\n",
       " '100569291': {'OKTMO': ['11552000']},\n",
       " '100569292': {'OKTMO': ['11552000']},\n",
       " '100569293': {'OKTMO': ['11552000']},\n",
       " '100569294': {'OKTMO': ['11552000']},\n",
       " '100569295': {'OKTMO': ['11552000']},\n",
       " '100569296': {'OKTMO': ['11552000']},\n",
       " '100569297': {'OKTMO': ['11552000']},\n",
       " '100569298': {'OKTMO': ['11552000']},\n",
       " '100569299': {'OKTMO': ['11552000']},\n",
       " '100569300': {'OKTMO': ['11552000']},\n",
       " '100569301': {'OKTMO': ['11552000']},\n",
       " '100569302': {'OKTMO': ['11552000']},\n",
       " '100569337': {'OKTMO': ['11552000']},\n",
       " '100569338': {'OKTMO': ['11552000']},\n",
       " '100569339': {'OKTMO': ['11552000']},\n",
       " '100569340': {'OKTMO': ['11552000']},\n",
       " '100569341': {'OKTMO': ['11552000']},\n",
       " '100569342': {'OKTMO': ['11552000']},\n",
       " '100569343': {'OKTMO': ['11552000']},\n",
       " '100569344': {'OKTMO': ['11552000']},\n",
       " '100569345': {'OKTMO': ['11552000']},\n",
       " '100569346': {'OKTMO': ['11552000']},\n",
       " '100569347': {'OKTMO': ['11552000']},\n",
       " '100569348': {'OKTMO': ['11552000']},\n",
       " '100569349': {'OKTMO': ['11552000']},\n",
       " '100569350': {'OKTMO': ['11552000']},\n",
       " '100569351': {'OKTMO': ['11552000']},\n",
       " '100569352': {'OKTMO': ['11552000']},\n",
       " '100569353': {'OKTMO': ['11552000']},\n",
       " '100569354': {'OKTMO': ['11552000']},\n",
       " '100569355': {'OKTMO': ['11552000']},\n",
       " '100569356': {'OKTMO': ['11552000']},\n",
       " '100570654': {'OKTMO': ['11552000']},\n",
       " '100570655': {'OKTMO': ['11552000']},\n",
       " '100570656': {'OKTMO': ['11552000']},\n",
       " '100570657': {'OKTMO': ['11552000']},\n",
       " '100570658': {'OKTMO': ['11552000']},\n",
       " '100570659': {'OKTMO': ['11552000']},\n",
       " '100570660': {'OKTMO': ['11552000']},\n",
       " '100570661': {'OKTMO': ['11552000']},\n",
       " '100570662': {'OKTMO': ['11552000']},\n",
       " '100570663': {'OKTMO': ['11552000']},\n",
       " '100570664': {'OKTMO': ['11552000']},\n",
       " '100570665': {'OKTMO': ['11552000']},\n",
       " '100570666': {'OKTMO': ['11552000']},\n",
       " '100570667': {'OKTMO': ['11552000']},\n",
       " '100570668': {'OKTMO': ['11552000']},\n",
       " '100570669': {'OKTMO': ['11552000']},\n",
       " '100570670': {'OKTMO': ['11552000']},\n",
       " '100570671': {'OKTMO': ['11552000']},\n",
       " '100570672': {'OKTMO': ['11552000']},\n",
       " '100570673': {'OKTMO': ['11552000']},\n",
       " '100570674': {'OKTMO': ['11552000']},\n",
       " '100570675': {'OKTMO': ['11552000']},\n",
       " '100570676': {'OKTMO': ['11552000']},\n",
       " '100570677': {'OKTMO': ['11552000']},\n",
       " '100570678': {'OKTMO': ['11552000']},\n",
       " '100570679': {'OKTMO': ['11552000']},\n",
       " '100570680': {'OKTMO': ['11552000']},\n",
       " '100570681': {'OKTMO': ['11552000']},\n",
       " '100570682': {'OKTMO': ['11552000']},\n",
       " '100570683': {'OKTMO': ['11552000']},\n",
       " '100570684': {'OKTMO': ['11552000']},\n",
       " '100570685': {'OKTMO': ['11552000']},\n",
       " '100570686': {'OKTMO': ['11552000']},\n",
       " '100570687': {'OKTMO': ['11552000']},\n",
       " '100570688': {'OKTMO': ['11552000']},\n",
       " '100570689': {'OKTMO': ['11552000']},\n",
       " '100570690': {'OKTMO': ['11552000']},\n",
       " '100570691': {'OKTMO': ['11552000']},\n",
       " '100570692': {'OKTMO': ['11552000']},\n",
       " '100570693': {'OKTMO': ['11552000']},\n",
       " '100570695': {'OKTMO': ['11552000']},\n",
       " '100570696': {'OKTMO': ['11552000']},\n",
       " '100570697': {'OKTMO': ['11552000']},\n",
       " '100570698': {'OKTMO': ['11552000']},\n",
       " '100570699': {'OKTMO': ['11552000']},\n",
       " '100570700': {'OKTMO': ['11552000']},\n",
       " '100570701': {'OKTMO': ['11552000']},\n",
       " '100570702': {'OKTMO': ['11552000']},\n",
       " '100570714': {'OKTMO': ['11701000001']},\n",
       " '100570745': {'OKTMO': ['11558000001']},\n",
       " '100570915': {'OKTMO': ['11730000126']},\n",
       " '100570920': {'OKTMO': ['11730000126']},\n",
       " '100570924': {'OKTMO': ['11730000126']},\n",
       " '100570928': {'OKTMO': ['11730000126']},\n",
       " '100571898': {'OKTMO': ['11730000126']},\n",
       " '100574360': {'OKTMO': ['11730000']},\n",
       " '100574780': {'OKTMO': ['11605456106']},\n",
       " '100574804': {'OKTMO': ['11605456106']},\n",
       " '100574925': {'OKTMO': ['11730000']},\n",
       " '100575108': {'OKTMO': ['11605456106']},\n",
       " '10057513': {'OKTMO': ['11627180106']},\n",
       " '100575247': {'OKTMO': ['11605456106']},\n",
       " '10057810': {'OKTMO': ['11527000114']},\n",
       " '100578799': {'OKTMO': ['11518000826']},\n",
       " '100579017': {'OKTMO': ['11518000001']},\n",
       " '100580439': {'OKTMO': ['11556000193']},\n",
       " '10058466': {'OKTMO': ['11527000114']},\n",
       " '10058904': {'OKTMO': ['11627180106']},\n",
       " '10059121': {'OKTMO': ['11552000259']},\n",
       " '100593062': {'OKTMO': ['11554000051']},\n",
       " '100593073': {'OKTMO': ['11554000559']},\n",
       " '100593087': {'OKTMO': ['11701000001']},\n",
       " '100593102': {'OKTMO': ['11701000001']},\n",
       " '100594145': {'OKTMO': ['11556000729']},\n",
       " '100595727': {'OKTMO': ['11552000']},\n",
       " '100595759': {'OKTMO': ['11556000501']},\n",
       " '100595780': {'OKTMO': ['11530000103']},\n",
       " '100595833': {'OKTMO': ['11556000719']},\n",
       " '100596307': {'OKTMO': ['11556000869']},\n",
       " '10059846': {'OKTMO': ['11552000259']},\n",
       " '100599123': {'OKTMO': ['11730000106']},\n",
       " '100599130': {'OKTMO': ['11730000126']},\n",
       " '100599132': {'OKTMO': ['11730000126']},\n",
       " '100599136': {'OKTMO': ['11730000001']},\n",
       " '100600120': {'OKTMO': ['11558000823']},\n",
       " '100600123': {'OKTMO': ['11635157051']},\n",
       " '100603042': {'OKTMO': ['11552000115']},\n",
       " '100603067': {'OKTMO': ['11552000128']},\n",
       " '10060613': {'OKTMO': ['11552000259']},\n",
       " '100606555': {'OKTMO': ['11508000890']},\n",
       " '100606763': {'OKTMO': ['11554000709']},\n",
       " '100606912': {'OKTMO': ['11552000']},\n",
       " '100609252': {'OKTMO': ['11527000']},\n",
       " '100609626': {'OKTMO': ['11605448221']},\n",
       " '100613288': {'OKTMO': ['11554000610']},\n",
       " '100617260': {'OKTMO': ['11552000']},\n",
       " '100618208': {'OKTMO': ['11701000001']},\n",
       " '100618330': {'OKTMO': ['11550000051']},\n",
       " '100618343': {'OKTMO': ['11701000001']},\n",
       " '100618721': {'OKTMO': ['11605101001']},\n",
       " '10061963': {'OKTMO': ['11552000259']},\n",
       " '100620556': {'OKTMO': ['11550000051']},\n",
       " '100620785': {'OKTMO': ['11550000051']},\n",
       " '100621090': {'OKTMO': ['11550000051']},\n",
       " '100622868': {'OKTMO': ['11552000185']},\n",
       " '10062383': {'OKTMO': ['11552000259']},\n",
       " '100625607': {'OKTMO': ['11605101001']},\n",
       " '100625628': {'OKTMO': ['11514000481']},\n",
       " '100627917': {'OKTMO': ['11605448221']},\n",
       " '10063325': {'OKTMO': ['11552000259']},\n",
       " '100635127': {'OKTMO': ['11710000056']},\n",
       " '100648060': {'OKTMO': ['11552000']},\n",
       " '100648063': {'OKTMO': ['11552000297']},\n",
       " '100649245': {'OKTMO': ['11552000']},\n",
       " '100649271': {'OKTMO': ['11552000253']},\n",
       " '100649276': {'OKTMO': ['11552000176']},\n",
       " '100653489': {'OKTMO': ['11605420101']},\n",
       " '100653869': {'OKTMO': ['11708000001']},\n",
       " '100654085': {'OKTMO': ['11708000001']},\n",
       " '100654280': {'OKTMO': ['11708000001']},\n",
       " '100654401': {'OKTMO': ['11725000001']},\n",
       " '100655065': {'OKTMO': ['11518000001']},\n",
       " '100655460': {'OKTMO': ['11552000']},\n",
       " '100656007': {'OKTMO': ['11635157166']},\n",
       " '100660229': {'OKTMO': ['11552000']},\n",
       " '100660251': {'OKTMO': ['11552000']},\n",
       " '100672824': {'OKTMO': ['11701000001']},\n",
       " '100673647': {'OKTMO': ['11622418206']},\n",
       " '100677250': {'OKTMO': ['11554000688']},\n",
       " '100682559': {'OKTMO': ['11635420101']},\n",
       " '100682591': {'OKTMO': ['11552000286']},\n",
       " '100682744': {'OKTMO': ['11514000281']},\n",
       " '100685848': {'OKTMO': ['11701000001']},\n",
       " '100685879': {'OKTMO': ['11701000001']},\n",
       " '100700370': {'OKTMO': ['11552000134']},\n",
       " '100700490': {'OKTMO': ['11605448221']},\n",
       " '100700686': {'OKTMO': ['11552000217']},\n",
       " '100700697': {'OKTMO': ['11605448151']},\n",
       " '100702809': {'OKTMO': ['11514000326']},\n",
       " '100703979': {'OKTMO': ['11527000304']},\n",
       " '100704261': {'OKTMO': ['11527000148']},\n",
       " '100704784': {'OKTMO': ['11552000232']},\n",
       " '100707085': {'OKTMO': ['11554000051']},\n",
       " '100710053': {'OKTMO': ['11552000260']},\n",
       " '100710186': {'OKTMO': ['11552000260']},\n",
       " '100710388': {'OKTMO': ['11552000118']},\n",
       " '100712307': {'OKTMO': ['11527000606']},\n",
       " '100718952': {'OKTMO': ['11725000001']},\n",
       " '100718954': {'OKTMO': ['11725000001']},\n",
       " '100718959': {'OKTMO': ['11725000001']},\n",
       " '100718965': {'OKTMO': ['11725000001']},\n",
       " '100718977': {'OKTMO': ['11725000001']},\n",
       " '100718979': {'OKTMO': ['11725000001']},\n",
       " '100718998': {'OKTMO': ['11725000001']},\n",
       " '100721060': {'OKTMO': ['11548000101']},\n",
       " '100721955': {'OKTMO': ['11527000']},\n",
       " '100721984': {'OKTMO': ['11527000']},\n",
       " '100723304': {'OKTMO': ['11518000358']},\n",
       " '100734136': {'OKTMO': ['11708000001']},\n",
       " '100734719': {'OKTMO': ['11622418101']},\n",
       " '100737794': {'OKTMO': ['11605402126']},\n",
       " '100740162': {'OKTMO': ['11552000260']},\n",
       " '100741340': {'OKTMO': ['11518000157']},\n",
       " '100747334': {'OKTMO': ['11527000']},\n",
       " '100747371': {'OKTMO': ['11527000']},\n",
       " '100747378': {'OKTMO': ['11527000']},\n",
       " '100747391': {'OKTMO': ['11527000']},\n",
       " '100747419': {'OKTMO': ['11527000']},\n",
       " '100747446': {'OKTMO': ['11527000698']},\n",
       " '100747458': {'OKTMO': ['11527000']},\n",
       " '100748355': {'OKTMO': ['11552000147']},\n",
       " '100748697': {'OKTMO': ['11527000']},\n",
       " '100749796': {'OKTMO': ['11646101001']},\n",
       " '100749985': {'OKTMO': ['11550000304']},\n",
       " '100751415': {'OKTMO': ['11554000349']},\n",
       " '100753485': {'OKTMO': ['11552000243']},\n",
       " '100754742': {'OKTMO': ['11622425126']},\n",
       " '100756742': {'OKTMO': ['11622151051']},\n",
       " '100761152': {'OKTMO': ['11554000322']},\n",
       " '100762552': {'OKTMO': ['11552000']},\n",
       " '100765191': {'OKTMO': ['11527000670']},\n",
       " '100767289': {'OKTMO': ['11552000185']},\n",
       " '100768963': {'OKTMO': ['11710000001']},\n",
       " '100768970': {'OKTMO': ['11710000056']},\n",
       " '100768987': {'OKTMO': ['11710000001']},\n",
       " '100769779': {'OKTMO': ['11556000911']},\n",
       " '100769793': {'OKTMO': ['11556000911']},\n",
       " '100769818': {'OKTMO': ['11556000911']},\n",
       " '100771126': {'OKTMO': ['11556000911']},\n",
       " '100771416': {'OKTMO': ['11552000']},\n",
       " '100774200': {'OKTMO': ['11554000349']},\n",
       " '100775595': {'OKTMO': ['11710000001']},\n",
       " '10077767': {'OKTMO': ['11518000751']},\n",
       " '100780749': {'OKTMO': ['11552000']},\n",
       " '100780751': {'OKTMO': ['11552000']},\n",
       " '100780755': {'OKTMO': ['11552000']},\n",
       " '100780758': {'OKTMO': ['11552000']},\n",
       " '100780760': {'OKTMO': ['11552000']},\n",
       " '100780763': {'OKTMO': ['11552000']},\n",
       " '100780766': {'OKTMO': ['11552000']},\n",
       " '100780769': {'OKTMO': ['11552000']},\n",
       " '100780771': {'OKTMO': ['11552000']},\n",
       " '100780774': {'OKTMO': ['11552000']},\n",
       " '10078085': {'OKTMO': ['11518000751']},\n",
       " '100784046': {'OKTMO': ['11550000']},\n",
       " '100784806': {'OKTMO': ['11605101001']},\n",
       " '100786071': {'OKTMO': ['11552000']},\n",
       " '100786185': {'OKTMO': ['11552000']},\n",
       " '100786257': {'OKTMO': ['11552000']},\n",
       " '100787427': {'OKTMO': ['11552000']},\n",
       " '100787479': {'OKTMO': ['11552000']},\n",
       " '100787513': {'OKTMO': ['11552000']},\n",
       " '100787582': {'OKTMO': ['11552000']},\n",
       " '100787723': {'OKTMO': ['11552000']},\n",
       " '100788079': {'OKTMO': ['11552000']},\n",
       " '100788126': {'OKTMO': ['11552000']},\n",
       " '100788314': {'OKTMO': ['11552000']},\n",
       " '100788437': {'OKTMO': ['11552000']},\n",
       " '100790728': {'OKTMO': ['11605101001']},\n",
       " '100791243': {'OKTMO': ['11552000']},\n",
       " '100793446': {'OKTMO': ['11518000826']},\n",
       " '100798393': {'OKTMO': ['11730000']},\n",
       " '100798639': {'OKTMO': ['11730000001']},\n",
       " '100798641': {'OKTMO': ['11527000152']},\n",
       " '100798644': {'OKTMO': ['11527000698']},\n",
       " '100802591': {'OKTMO': ['11558000001']},\n",
       " '100802987': {'OKTMO': ['11511000390']},\n",
       " '100804216': {'OKTMO': ['11605101001']},\n",
       " '100804867': {'OKTMO': ['11552000167']},\n",
       " '100804878': {'OKTMO': ['11552000167']},\n",
       " '100804896': {'OKTMO': ['11552000167']},\n",
       " '100804908': {'OKTMO': ['11552000167']},\n",
       " '100805599': {'OKTMO': ['11635157051']},\n",
       " '10080704': {'OKTMO': ['11518000751']},\n",
       " '100812933': {'OKTMO': ['11635157051']},\n",
       " '100812936': {'OKTMO': ['11635157121']},\n",
       " '100812942': {'OKTMO': ['11552000']},\n",
       " '100812955': {'OKTMO': ['11552000282']},\n",
       " '100812975': {'OKTMO': ['11550000061']},\n",
       " '100812983': {'OKTMO': ['11554000051']},\n",
       " '100813078': {'OKTMO': ['11701000001']},\n",
       " '100813082': {'OKTMO': ['11715000001']},\n",
       " '100814553': {'OKTMO': ['11635420231']},\n",
       " '100815352': {'OKTMO': ['11701000001']},\n",
       " '10081761': {'OKTMO': ['11518000751']},\n",
       " '100817769': {'OKTMO': ['11708000001']},\n",
       " '100818786': {'OKTMO': ['11622418126']},\n",
       " '100818794': {'OKTMO': ['11605101001']},\n",
       " '100824781': {'OKTMO': ['11552000215']},\n",
       " '100825139': {'OKTMO': ['11552000156']},\n",
       " '100825272': {'OKTMO': ['11552000237']},\n",
       " '100829928': {'OKTMO': ['11635157051']},\n",
       " '100831106': {'OKTMO': ['11514000301']},\n",
       " '100831142': {'OKTMO': ['11514000551']},\n",
       " '100831269': {'OKTMO': ['11708000001']},\n",
       " '100831290': {'OKTMO': ['11552000286']},\n",
       " '100831301': {'OKTMO': ['11552000286']},\n",
       " '100831855': {'OKTMO': ['11635420101']},\n",
       " '100831856': {'OKTMO': ['11708000001']},\n",
       " '100831983': {'OKTMO': ['11708000001']},\n",
       " '100837396': {'OKTMO': ['11635157051']},\n",
       " '100839384': {'OKTMO': ['11511000762']},\n",
       " '100839397': {'OKTMO': ['11701000001']},\n",
       " '100839888': {'OKTMO': ['11701000001']},\n",
       " '100840197': {'OKTMO': ['11511000618']},\n",
       " '100840372': {'OKTMO': ['11552000286']},\n",
       " '100840450': {'OKTMO': ['11552000286']},\n",
       " '100840559': {'OKTMO': ['11605101001']},\n",
       " '100840563': {'OKTMO': ['11511000170']},\n",
       " '100841083': {'OKTMO': ['11527000444']},\n",
       " '100842071': {'OKTMO': ['11548000186']},\n",
       " '100847035': {'OKTMO': ['11552000']},\n",
       " '100847370': {'OKTMO': ['11708000001']},\n",
       " '100847384': {'OKTMO': ['11554000610']},\n",
       " '100849365': {'OKTMO': ['11548000101']},\n",
       " '100849445': {'OKTMO': ['11552000271']},\n",
       " '100850034': {'OKTMO': ['11548000107']},\n",
       " '100851873': {'OKTMO': ['11708000001']},\n",
       " '100854008': {'OKTMO': ['11730000']},\n",
       " '100854020': {'OKTMO': ['11730000']},\n",
       " '100854053': {'OKTMO': ['11730000']},\n",
       " '100855064': {'OKTMO': ['11730000']},\n",
       " '100855081': {'OKTMO': ['11710000001']},\n",
       " '100855127': {'OKTMO': ['11710000001']},\n",
       " '100855133': {'OKTMO': ['11730000']},\n",
       " '100855149': {'OKTMO': ['11710000001']},\n",
       " '100857926': {'OKTMO': ['11730000']},\n",
       " '100859314': {'OKTMO': ['11538000101']},\n",
       " '100864889': {'OKTMO': ['11622151051']},\n",
       " '100866387': {'OKTMO': ['11701000001']},\n",
       " '100866659': {'OKTMO': ['11518000001']},\n",
       " '100866766': {'OKTMO': ['11518000001']},\n",
       " '100866779': {'OKTMO': ['11518000001']},\n",
       " '100866791': {'OKTMO': ['11518000001']},\n",
       " '100866807': {'OKTMO': ['11518000001']},\n",
       " '100866823': {'OKTMO': ['11518000001']},\n",
       " '100866834': {'OKTMO': ['11518000001']},\n",
       " '100866885': {'OKTMO': ['11518000001']},\n",
       " '100870976': {'OKTMO': ['11518000685']},\n",
       " '100870986': {'OKTMO': ['11518000229']},\n",
       " '100870995': {'OKTMO': ['11518000739']},\n",
       " '100871017': {'OKTMO': ['11518000379']},\n",
       " '100871037': {'OKTMO': ['11518000613']},\n",
       " '100871043': {'OKTMO': ['11518000613']},\n",
       " '100871050': {'OKTMO': ['11518000613']},\n",
       " '100871992': {'OKTMO': ['11635157051']},\n",
       " '100872318': {'OKTMO': ['11550000802']},\n",
       " '100872353': {'OKTMO': ['11550000802']},\n",
       " '100876632': {'OKTMO': ['11538000266']},\n",
       " '100876732': {'OKTMO': ['11538000101']},\n",
       " '100878836': {'OKTMO': ['11635157051']},\n",
       " '100879000': {'OKTMO': ['11635157051']},\n",
       " '100883530': {'OKTMO': ['11605101001']},\n",
       " '100883559': {'OKTMO': ['11605101001']},\n",
       " '100883609': {'OKTMO': ['11518000001']},\n",
       " '100883979': {'OKTMO': ['11527000']},\n",
       " '100884032': {'OKTMO': ['11527000']},\n",
       " '100884039': {'OKTMO': ['11527000']},\n",
       " '100884052': {'OKTMO': ['11527000']},\n",
       " '100884063': {'OKTMO': ['11527000']},\n",
       " '100899233': {'OKTMO': ['11710000056']},\n",
       " '100899238': {'OKTMO': ['11710000056']},\n",
       " '100899242': {'OKTMO': ['11710000056']},\n",
       " '100899259': {'OKTMO': ['11552000211']},\n",
       " '100899261': {'OKTMO': ['11552000224']},\n",
       " '100905370': {'OKTMO': ['11554000418']},\n",
       " '100908213': {'OKTMO': ['11622418101']},\n",
       " '100908302': {'OKTMO': ['11530000101']},\n",
       " '100910689': {'OKTMO': ['11554000157']},\n",
       " '100910694': {'OKTMO': ['11635420101']},\n",
       " '100912995': {'OKTMO': ['11552000']},\n",
       " '100913102': {'OKTMO': ['11552000']},\n",
       " '100913497': {'OKTMO': ['11552000']},\n",
       " '100913804': {'OKTMO': ['11552000268']},\n",
       " '100913878': {'OKTMO': ['11552000260']},\n",
       " '10091744': {'OKTMO': ['11527000150']},\n",
       " '100919982': {'OKTMO': ['11635420101']},\n",
       " '100919993': {'OKTMO': ['11552000243']},\n",
       " '100919997': {'OKTMO': ['11556000889']},\n",
       " '100921155': {'OKTMO': ['11548000208']},\n",
       " '10092216': {'OKTMO': ['11527000150']},\n",
       " '100923712': {'OKTMO': ['11554000784']},\n",
       " '100924123': {'OKTMO': ['11646403101']},\n",
       " '100924662': {'OKTMO': ['11552000282']},\n",
       " '10092930': {'OKTMO': ['11527000150']},\n",
       " '100929753': {'OKTMO': ['11550000802']},\n",
       " '100929761': {'OKTMO': ['11550000061']},\n",
       " '100932576': {'OKTMO': ['11542000111']},\n",
       " '100933106': {'OKTMO': ['11542000136']},\n",
       " '100933107': {'OKTMO': ['11542000136']},\n",
       " '100933108': {'OKTMO': ['11542000136']},\n",
       " '100933109': {'OKTMO': ['11542000136']},\n",
       " '100933110': {'OKTMO': ['11542000136']},\n",
       " '100933111': {'OKTMO': ['11542000136']},\n",
       " '100933234': {'OKTMO': ['11552000']},\n",
       " '100934766': {'OKTMO': ['11514000101']},\n",
       " '100934783': {'OKTMO': ['11514000101']},\n",
       " '100934812': {'OKTMO': ['11514000101']},\n",
       " '10093558': {'OKTMO': ['11527000150']},\n",
       " '10093952': {'OKTMO': ['11527000150']},\n",
       " '100940324': {'OKTMO': ['11554000601']},\n",
       " '100940326': {'OKTMO': ['11605420101']},\n",
       " '100944175': {'OKTMO': ['11527000282']},\n",
       " '10094425': {'OKTMO': ['11527000150']},\n",
       " '100944650': {'OKTMO': ['11605420111']},\n",
       " '100944687': {'OKTMO': ['11605420111']},\n",
       " '100944806': {'OKTMO': ['11605420101']},\n",
       " '100947110': {'OKTMO': ['11554000244']},\n",
       " '100947120': {'OKTMO': ['11554000244']},\n",
       " '100947278': {'OKTMO': ['11554000244']},\n",
       " '100948105': {'OKTMO': ['11552000195']},\n",
       " '100949325': {'OKTMO': ['11508000890']},\n",
       " '100950101': {'OKTMO': ['11635157051']},\n",
       " '100950248': {'OKTMO': ['11556000757']},\n",
       " '100950805': {'OKTMO': ['11556000543']},\n",
       " '100951444': {'OKTMO': ['11605420101']},\n",
       " '100952377': {'OKTMO': ['11622432256']},\n",
       " '100953043': {'OKTMO': ['11554000244']},\n",
       " '10095694': {'OKTMO': ['11527000150']},\n",
       " '10095800': {'OKTMO': ['11527000150']},\n",
       " '100958155': {'OKTMO': ['11605101001']},\n",
       " '100958158': {'OKTMO': ['11552000']},\n",
       " '100958649': {'OKTMO': ['11710000001']},\n",
       " '100959091': {'OKTMO': ['11552000295']},\n",
       " '100959207': {'OKTMO': ['11552000183']},\n",
       " '100960782': {'OKTMO': ['11550000051']},\n",
       " '100960790': {'OKTMO': ['11550000051']},\n",
       " '100960834': {'OKTMO': ['11550000051']},\n",
       " '100960845': {'OKTMO': ['11550000051']},\n",
       " '100961929': {'OKTMO': ['11550000051']},\n",
       " '100962058': {'OKTMO': ['11552000211']},\n",
       " '100962107': {'OKTMO': ['11552000211']},\n",
       " '100962768': {'OKTMO': ['11542000331']},\n",
       " '10096334': {'OKTMO': ['11527000150']},\n",
       " '100964050': {'OKTMO': ['11552000185']},\n",
       " '100964287': {'OKTMO': ['11605101001']},\n",
       " '10096537': {'OKTMO': ['11527000150']},\n",
       " '100967766': {'OKTMO': ['11527000566']},\n",
       " '10096825': {'OKTMO': ['11527000150']},\n",
       " '100968687': {'OKTMO': ['11708000001']},\n",
       " '100969468': {'OKTMO': ['11605418141']},\n",
       " '100969550': {'OKTMO': ['11708000001']},\n",
       " '10097230': {'OKTMO': ['11527000150']},\n",
       " '100973720': {'OKTMO': ['11542000111']},\n",
       " '100976239': {'OKTMO': ['11552000286']},\n",
       " '100976251': {'OKTMO': ['11552000286']},\n",
       " '10097715': {'OKTMO': ['11527000150']},\n",
       " '100977255': {'OKTMO': ['11552000288']},\n",
       " '100977790': {'OKTMO': ['11556000437']},\n",
       " '100977845': {'OKTMO': ['11550000736']},\n",
       " '100978021': {'OKTMO': ['11550000736']},\n",
       " '100978105': {'OKTMO': ['11550000736']},\n",
       " '100978175': {'OKTMO': ['11550000051']},\n",
       " '100978196': {'OKTMO': ['11550000051']},\n",
       " '100978218': {'OKTMO': ['11550000051']},\n",
       " '100978233': {'OKTMO': ['11550000051']},\n",
       " '100978255': {'OKTMO': ['11550000051']},\n",
       " '100978283': {'OKTMO': ['11550000051']},\n",
       " '10098604': {'OKTMO': ['11527000150']},\n",
       " '100986382': {'OKTMO': ['11710000056']},\n",
       " '100986384': {'OKTMO': ['11710000056']},\n",
       " '100986386': {'OKTMO': ['11710000056']},\n",
       " '100987368': {'OKTMO': ['11527000246']},\n",
       " '10098833': {'OKTMO': ['11527000150']},\n",
       " '100988364': {'OKTMO': ['11635157121']},\n",
       " '100988367': {'OKTMO': ['11701000001']},\n",
       " '100988391': {'OKTMO': ['11508000101']},\n",
       " '100988392': {'OKTMO': ['11508000101']},\n",
       " '100988401': {'OKTMO': ['11554000127']},\n",
       " '100989149': {'OKTMO': ['11527000606']},\n",
       " '100989459': {'OKTMO': ['11527000304']},\n",
       " '100989465': {'OKTMO': ['11550000051']},\n",
       " '100990796': {'OKTMO': ['11622418221']},\n",
       " '10099460': {'OKTMO': ['11527000150']},\n",
       " '100995632': {'OKTMO': ['11605448196']},\n",
       " '100995638': {'OKTMO': ['11556000851']},\n",
       " '100995687': {'OKTMO': ['11605456106']},\n",
       " '100995722': {'OKTMO': ['11605456106']},\n",
       " '10099609': {'OKTMO': ['11622432101']},\n",
       " '10099802': {'OKTMO': ['11527000150']},\n",
       " '10099908': {'OKTMO': ['11527000150']},\n",
       " '10100027': {'OKTMO': ['11622432101']},\n",
       " '10100058': {'OKTMO': ['11527000150']},\n",
       " '101000786': {'OKTMO': ['11552000']},\n",
       " '101000808': {'OKTMO': ['11715000001']},\n",
       " '101003735': {'OKTMO': ['11710000001']},\n",
       " '101004187': {'OKTMO': ['11554000610']},\n",
       " '101006736': {'OKTMO': ['11710000001']},\n",
       " '10101158': {'OKTMO': ['11622432101']},\n",
       " '101011596': {'OKTMO': ['11622418101']},\n",
       " '101012176': {'OKTMO': ['11635420101']},\n",
       " '101012275': {'OKTMO': ['11518000736']},\n",
       " '101012502': {'OKTMO': ['11635420101']},\n",
       " '101013673': {'OKTMO': ['11552000295']},\n",
       " '10102215': {'OKTMO': ['11622432101']},\n",
       " '10102563': {'OKTMO': ['11527000150']},\n",
       " '101029367': {'OKTMO': ['11530000137']},\n",
       " '101029400': {'OKTMO': ['11530000137']},\n",
       " '10102958': {'OKTMO': ['11622432101']},\n",
       " '101029694': {'OKTMO': ['11530000170']},\n",
       " '101030262': {'OKTMO': ['11558000784']},\n",
       " '10103039': {'OKTMO': ['11527000150']},\n",
       " '101031147': {'OKTMO': ['11558000784']},\n",
       " '101031186': {'OKTMO': ['11558000784']},\n",
       " '101031226': {'OKTMO': ['11558000784']},\n",
       " '101031521': {'OKTMO': ['11635157051']},\n",
       " '101031988': {'OKTMO': ['11715000001']},\n",
       " '101033519': {'OKTMO': ['11552000']},\n",
       " '101033534': {'OKTMO': ['11552000295']},\n",
       " '101033564': {'OKTMO': ['11552000']},\n",
       " '101033690': {'OKTMO': ['11552000']},\n",
       " '101033719': {'OKTMO': ['11552000']},\n",
       " '101033751': {'OKTMO': ['11552000']},\n",
       " '10103405': {'OKTMO': ['11527000150']},\n",
       " '10103664': {'OKTMO': ['11622432101']},\n",
       " '101037870': {'OKTMO': ['11715000001']},\n",
       " '10103839': {'OKTMO': ['11527000150']},\n",
       " '10104043': {'OKTMO': ['11622432101']},\n",
       " '101041303': {'OKTMO': ['11552000']},\n",
       " '101041313': {'OKTMO': ['11552000']},\n",
       " '101041315': {'OKTMO': ['11542000306']},\n",
       " '101041323': {'OKTMO': ['11552000']},\n",
       " '101041405': {'OKTMO': ['11530000212']},\n",
       " '10104181': {'OKTMO': ['11527000150']},\n",
       " '101045897': {'OKTMO': ['11518000001']},\n",
       " '101046292': {'OKTMO': ['11538000101']},\n",
       " '10104636': {'OKTMO': ['11527000150']},\n",
       " '101049639': {'OKTMO': ['11701000001']},\n",
       " '101053419': {'OKTMO': ['11527000']},\n",
       " '10105356': {'OKTMO': ['11527000150']},\n",
       " '101054136': {'OKTMO': ['11538000101']},\n",
       " '101054304': {'OKTMO': ['11622418101']},\n",
       " '10105434': {'OKTMO': ['11622432101']},\n",
       " '101054342': {'OKTMO': ['11622418101']},\n",
       " '101054343': {'OKTMO': ['11622418101']},\n",
       " '101054344': {'OKTMO': ['11622418101']},\n",
       " '101054371': {'OKTMO': ['11622418101']},\n",
       " '101054372': {'OKTMO': ['11622418101']},\n",
       " '101054393': {'OKTMO': ['11622418101']},\n",
       " '101054399': {'OKTMO': ['11622418101']},\n",
       " '101054414': {'OKTMO': ['11622418101']},\n",
       " '101054415': {'OKTMO': ['11622418101']},\n",
       " '101054458': {'OKTMO': ['11622418101']},\n",
       " '101054459': {'OKTMO': ['11622418101']},\n",
       " '101054460': {'OKTMO': ['11622418101']},\n",
       " '101054470': {'OKTMO': ['11622418101']},\n",
       " '101054489': {'OKTMO': ['11622418101']},\n",
       " '101054490': {'OKTMO': ['11622418101']},\n",
       " '101054506': {'OKTMO': ['11622418101']},\n",
       " '101054507': {'OKTMO': ['11622418101']},\n",
       " '101054523': {'OKTMO': ['11622418101']},\n",
       " '101054524': {'OKTMO': ['11622418101']},\n",
       " '101054525': {'OKTMO': ['11622418101']},\n",
       " '101054536': {'OKTMO': ['11622418101']},\n",
       " '101054537': {'OKTMO': ['11622418101']},\n",
       " '101054545': {'OKTMO': ['11622418101']},\n",
       " '101054546': {'OKTMO': ['11622418101']},\n",
       " '101054559': {'OKTMO': ['11622418101']},\n",
       " '101054560': {'OKTMO': ['11622418101']},\n",
       " '101054584': {'OKTMO': ['11622418101']},\n",
       " '101054585': {'OKTMO': ['11622418101']},\n",
       " ...}"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hp = hp[['OBJECTID', 'VALUE']].rename(\n",
    "    columns={'VALUE': 'OKTMO'}\n",
    ").drop_duplicates().groupby(\n",
    "    by='OBJECTID'\n",
    ").agg(\n",
    "    lambda x: x.to_list()\n",
    ").to_dict('index')\n",
    "hp"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Конкатенация адресных объектов с объектами домов"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>HOUSENUM</th>\n",
       "      <th>HOUSENUM1</th>\n",
       "      <th>HOUSENUM2</th>\n",
       "      <th>HOUSETYPE</th>\n",
       "      <th>HOUSETYPE1</th>\n",
       "      <th>HOUSETYPE2</th>\n",
       "      <th>ISACTIVE</th>\n",
       "      <th>ISACTUAL</th>\n",
       "      <th>LEVEL</th>\n",
       "      <th>LEVELNAME</th>\n",
       "      <th>...</th>\n",
       "      <th>NAME1</th>\n",
       "      <th>NAME2</th>\n",
       "      <th>OBJECTGUID</th>\n",
       "      <th>OBJECTID</th>\n",
       "      <th>TYPELONGNAME</th>\n",
       "      <th>TYPELONGNAME1</th>\n",
       "      <th>TYPELONGNAME2</th>\n",
       "      <th>TYPENAME</th>\n",
       "      <th>TYPENAME1</th>\n",
       "      <th>TYPENAME2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "      <td>Элемент планировочной структуры</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>425d519f-3636-41bd-ae7e-0c284911ada9</td>\n",
       "      <td>445407</td>\n",
       "      <td>Территория садоводческого некоммерческого това...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>тер. СНТ</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>Сельское/городское поселение</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>6621d717-388a-4533-9571-142c34a22acc</td>\n",
       "      <td>95239078</td>\n",
       "      <td>сельское поселение</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>с.п.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>Сельское/городское поселение</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>42b314b1-95a4-406d-89bd-d81fc316f69c</td>\n",
       "      <td>95239091</td>\n",
       "      <td>сельское поселение</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>с.п.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>Сельское/городское поселение</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9e0cb420-4511-48a0-bac1-966f6170bfc7</td>\n",
       "      <td>95239119</td>\n",
       "      <td>сельское поселение</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>с.п.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>Муниципальный район</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>413ad5f9-fb3d-431e-8619-0376df3e9f4b</td>\n",
       "      <td>95239186</td>\n",
       "      <td>Городской округ</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>г.о.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 21 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "  HOUSENUM HOUSENUM1 HOUSENUM2 HOUSETYPE HOUSETYPE1 HOUSETYPE2 ISACTIVE  \\\n",
       "0      NaN       NaN       NaN       NaN        NaN        NaN        1   \n",
       "1      NaN       NaN       NaN       NaN        NaN        NaN        1   \n",
       "2      NaN       NaN       NaN       NaN        NaN        NaN        1   \n",
       "3      NaN       NaN       NaN       NaN        NaN        NaN        1   \n",
       "4      NaN       NaN       NaN       NaN        NaN        NaN        1   \n",
       "\n",
       "  ISACTUAL LEVEL                        LEVELNAME  ... NAME1 NAME2  \\\n",
       "0        1     7  Элемент планировочной структуры  ...   NaN   NaN   \n",
       "1        1     4     Сельское/городское поселение  ...   NaN   NaN   \n",
       "2        1     4     Сельское/городское поселение  ...   NaN   NaN   \n",
       "3        1     4     Сельское/городское поселение  ...   NaN   NaN   \n",
       "4        1     3              Муниципальный район  ...   NaN   NaN   \n",
       "\n",
       "                             OBJECTGUID  OBJECTID  \\\n",
       "0  425d519f-3636-41bd-ae7e-0c284911ada9    445407   \n",
       "1  6621d717-388a-4533-9571-142c34a22acc  95239078   \n",
       "2  42b314b1-95a4-406d-89bd-d81fc316f69c  95239091   \n",
       "3  9e0cb420-4511-48a0-bac1-966f6170bfc7  95239119   \n",
       "4  413ad5f9-fb3d-431e-8619-0376df3e9f4b  95239186   \n",
       "\n",
       "                                        TYPELONGNAME TYPELONGNAME1  \\\n",
       "0  Территория садоводческого некоммерческого това...           NaN   \n",
       "1                                 сельское поселение           NaN   \n",
       "2                                 сельское поселение           NaN   \n",
       "3                                 сельское поселение           NaN   \n",
       "4                                    Городской округ           NaN   \n",
       "\n",
       "  TYPELONGNAME2  TYPENAME TYPENAME1 TYPENAME2  \n",
       "0           NaN  тер. СНТ       NaN       NaN  \n",
       "1           NaN      с.п.       NaN       NaN  \n",
       "2           NaN      с.п.       NaN       NaN  \n",
       "3           NaN      с.п.       NaN       NaN  \n",
       "4           NaN      г.о.       NaN       NaN  \n",
       "\n",
       "[5 rows x 21 columns]"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hadobj = pd.concat(\n",
    "  [\n",
    "      adobj[[\n",
    "          'OBJECTID', 'OBJECTGUID', 'NAME', 'TYPENAME', 'LEVEL',\n",
    "          'ISACTUAL', 'ISACTIVE', 'TYPELONGNAME', 'LEVELNAME'\n",
    "      ]],\n",
    "      hous[[\n",
    "          'OBJECTID', 'OBJECTGUID', 'HOUSENUM', 'HOUSETYPE',\n",
    "          'TYPENAME', 'TYPELONGNAME', 'HOUSENUM1', 'HOUSETYPE1',\n",
    "          'TYPENAME1', 'TYPELONGNAME1', 'HOUSENUM2', 'HOUSETYPE2',\n",
    "          'TYPENAME2', 'TYPELONGNAME2', 'ISACTUAL', 'ISACTIVE',\n",
    "          'LEVEL', 'NAME', 'NAME1', 'NAME2', 'LEVELNAME'\n",
    "      ]]\n",
    "  ],\n",
    "  sort=True,\n",
    "  ignore_index=True\n",
    ")\n",
    "# cleanup(adobj)\n",
    "# cleanup(hous)\n",
    "hadobj.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 256541 entries, 0 to 256540\n",
      "Data columns (total 21 columns):\n",
      " #   Column         Non-Null Count   Dtype \n",
      "---  ------         --------------   ----- \n",
      " 0   HOUSENUM       242303 non-null  object\n",
      " 1   HOUSENUM1      26228 non-null   object\n",
      " 2   HOUSENUM2      2328 non-null    object\n",
      " 3   HOUSETYPE      242303 non-null  object\n",
      " 4   HOUSETYPE1     26228 non-null   object\n",
      " 5   HOUSETYPE2     2328 non-null    object\n",
      " 6   ISACTIVE       256541 non-null  object\n",
      " 7   ISACTUAL       256541 non-null  object\n",
      " 8   LEVEL          256541 non-null  object\n",
      " 9   LEVELNAME      256541 non-null  object\n",
      " 10  NAME           256541 non-null  object\n",
      " 11  NAME1          242303 non-null  object\n",
      " 12  NAME2          242303 non-null  object\n",
      " 13  OBJECTGUID     256541 non-null  object\n",
      " 14  OBJECTID       256541 non-null  object\n",
      " 15  TYPELONGNAME   256541 non-null  object\n",
      " 16  TYPELONGNAME1  26228 non-null   object\n",
      " 17  TYPELONGNAME2  2328 non-null    object\n",
      " 18  TYPENAME       256541 non-null  object\n",
      " 19  TYPENAME1      26228 non-null   object\n",
      " 20  TYPENAME2      2328 non-null    object\n",
      "dtypes: object(21)\n",
      "memory usage: 41.1+ MB\n"
     ]
    }
   ],
   "source": [
    "hadobj.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Чтение файлов административного деления"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>OBJECTID</th>\n",
       "      <th>PARENTOBJID</th>\n",
       "      <th>PATH</th>\n",
       "      <th>HOUSENUM</th>\n",
       "      <th>HOUSENUM1</th>\n",
       "      <th>HOUSENUM2</th>\n",
       "      <th>HOUSETYPE</th>\n",
       "      <th>HOUSETYPE1</th>\n",
       "      <th>HOUSETYPE2</th>\n",
       "      <th>ISACTIVE</th>\n",
       "      <th>...</th>\n",
       "      <th>NAME</th>\n",
       "      <th>NAME1</th>\n",
       "      <th>NAME2</th>\n",
       "      <th>OBJECTGUID</th>\n",
       "      <th>TYPELONGNAME</th>\n",
       "      <th>TYPELONGNAME1</th>\n",
       "      <th>TYPELONGNAME2</th>\n",
       "      <th>TYPENAME</th>\n",
       "      <th>TYPENAME1</th>\n",
       "      <th>TYPENAME2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>13476701</td>\n",
       "      <td>448314</td>\n",
       "      <td>442495.162031408.448314.13476701</td>\n",
       "      <td>8</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>дом 8</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>32b62af7-8a14-48f6-90dc-bdb781b07363</td>\n",
       "      <td>Дом</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>д.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>102928317</td>\n",
       "      <td>445172</td>\n",
       "      <td>442495.95239121.95239122.442679.445172.102928317</td>\n",
       "      <td>52</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>дом 52</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>8397faa6-d516-40f9-9798-b3f219884523</td>\n",
       "      <td>Дом</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>д.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>442995</td>\n",
       "      <td>443016</td>\n",
       "      <td>442495.162033520.443016.442995</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>15-я линия</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>34518b00-4697-4513-87fb-1ed04a08c7f3</td>\n",
       "      <td>Улица</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>ул</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>160940575</td>\n",
       "      <td>445390</td>\n",
       "      <td>442495.162033520.443524.445390.160940575</td>\n",
       "      <td>519</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>дом 519</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>d22799cc-4189-485d-8792-645cfa809f34</td>\n",
       "      <td>Дом</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>д.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>444492</td>\n",
       "      <td>442089</td>\n",
       "      <td>442495.162033520.442089.444492</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>5-я линия</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>f08d707d-62c2-496c-bc28-c1706e41c105</td>\n",
       "      <td>Улица</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>ул</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 23 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    OBJECTID PARENTOBJID                                              PATH  \\\n",
       "0   13476701      448314                  442495.162031408.448314.13476701   \n",
       "1  102928317      445172  442495.95239121.95239122.442679.445172.102928317   \n",
       "2     442995      443016                    442495.162033520.443016.442995   \n",
       "3  160940575      445390          442495.162033520.443524.445390.160940575   \n",
       "4     444492      442089                    442495.162033520.442089.444492   \n",
       "\n",
       "  HOUSENUM HOUSENUM1 HOUSENUM2 HOUSETYPE HOUSETYPE1 HOUSETYPE2 ISACTIVE  ...  \\\n",
       "0        8       NaN       NaN         2        NaN        NaN        1  ...   \n",
       "1       52       NaN       NaN         2        NaN        NaN        1  ...   \n",
       "2      NaN       NaN       NaN       NaN        NaN        NaN        1  ...   \n",
       "3      519       NaN       NaN         2        NaN        NaN        1  ...   \n",
       "4      NaN       NaN       NaN       NaN        NaN        NaN        1  ...   \n",
       "\n",
       "         NAME NAME1 NAME2                            OBJECTGUID TYPELONGNAME  \\\n",
       "0       дом 8              32b62af7-8a14-48f6-90dc-bdb781b07363          Дом   \n",
       "1      дом 52              8397faa6-d516-40f9-9798-b3f219884523          Дом   \n",
       "2  15-я линия   NaN   NaN  34518b00-4697-4513-87fb-1ed04a08c7f3        Улица   \n",
       "3     дом 519              d22799cc-4189-485d-8792-645cfa809f34          Дом   \n",
       "4   5-я линия   NaN   NaN  f08d707d-62c2-496c-bc28-c1706e41c105        Улица   \n",
       "\n",
       "  TYPELONGNAME1 TYPELONGNAME2 TYPENAME TYPENAME1 TYPENAME2  \n",
       "0           NaN           NaN       д.       NaN       NaN  \n",
       "1           NaN           NaN       д.       NaN       NaN  \n",
       "2           NaN           NaN       ул       NaN       NaN  \n",
       "3           NaN           NaN       д.       NaN       NaN  \n",
       "4           NaN           NaN       ул       NaN       NaN  \n",
       "\n",
       "[5 rows x 23 columns]"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fname = glob.glob(os.path.join(region, 'AS_MUN_HIERARCHY_*.XML'))\n",
    "if len(fname) != 1:\n",
    "    msg = f'Проверить количество файлов региона {region} там {len(fname)} файлов'\n",
    "    logger.error(msg)\n",
    "    raise Exception(msg)\n",
    "fname = fname[0]\n",
    "adm = parse_xml(fname)\n",
    "adm = adm[\n",
    "    adm.ENDDATE.apply(\n",
    "        lambda x: datetime.datetime.strptime(\n",
    "            x, '%Y-%m-%d'\n",
    "        ) > datetime.datetime.fromtimestamp(\n",
    "            time.time()\n",
    "        )\n",
    "    )\n",
    "]\n",
    "chready = 'PATH' in adm.columns\n",
    "cols = ['OBJECTID', 'PARENTOBJID'] + (['PATH'] if chready else [])\n",
    "adm0 = adm[adm['ISACTIVE'] == '1'][cols].merge(\n",
    "    hadobj[(hadobj['ISACTUAL'] == '1') & (hadobj['ISACTIVE'] == '1')],\n",
    "    on='OBJECTID'\n",
    ")\n",
    "cleanup(adm)\n",
    "adm0.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 242280/242280 [00:00<00:00, 680256.21it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "242280 [('13476701', '448314', '162031408', '442495'), ('102928317', '445172', '442679', '95239122', '95239121', '442495'), ('160940575', '445390', '443524', '162033520', '442495'), ('161958121', '446273', '162033520', '442495'), ('161980828', '446273', '162033520', '442495')]\n"
     ]
    }
   ],
   "source": [
    "if chready:\n",
    "    chains = [\n",
    "        tuple(y for y in reversed(x.split('.')))\n",
    "        for x in tqdm(adm0[adm0['LEVEL'] == '10']['PATH'])\n",
    "    ]\n",
    "    cleanup(adm0)\n",
    "    print(len(chains), chains[:5])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('445407',\n",
       "  {'HOUSENUM': nan,\n",
       "   'HOUSENUM1': nan,\n",
       "   'HOUSENUM2': nan,\n",
       "   'HOUSETYPE': nan,\n",
       "   'HOUSETYPE1': nan,\n",
       "   'HOUSETYPE2': nan,\n",
       "   'ISACTIVE': '1',\n",
       "   'ISACTUAL': '1',\n",
       "   'LEVEL': '7',\n",
       "   'LEVELNAME': 'Элемент планировочной структуры',\n",
       "   'NAME': 'Лисьи Борки',\n",
       "   'NAME1': nan,\n",
       "   'NAME2': nan,\n",
       "   'OBJECTGUID': '425d519f-3636-41bd-ae7e-0c284911ada9',\n",
       "   'TYPELONGNAME': 'Территория садоводческого некоммерческого товарищества',\n",
       "   'TYPELONGNAME1': nan,\n",
       "   'TYPELONGNAME2': nan,\n",
       "   'TYPENAME': 'тер. СНТ',\n",
       "   'TYPENAME1': nan,\n",
       "   'TYPENAME2': nan}),\n",
       " ('95239078',\n",
       "  {'HOUSENUM': nan,\n",
       "   'HOUSENUM1': nan,\n",
       "   'HOUSENUM2': nan,\n",
       "   'HOUSETYPE': nan,\n",
       "   'HOUSETYPE1': nan,\n",
       "   'HOUSETYPE2': nan,\n",
       "   'ISACTIVE': '1',\n",
       "   'ISACTUAL': '1',\n",
       "   'LEVEL': '4',\n",
       "   'LEVELNAME': 'Сельское/городское поселение',\n",
       "   'NAME': 'Тарасовское',\n",
       "   'NAME1': nan,\n",
       "   'NAME2': nan,\n",
       "   'OBJECTGUID': '6621d717-388a-4533-9571-142c34a22acc',\n",
       "   'TYPELONGNAME': 'сельское поселение',\n",
       "   'TYPELONGNAME1': nan,\n",
       "   'TYPELONGNAME2': nan,\n",
       "   'TYPENAME': 'с.п.',\n",
       "   'TYPENAME1': nan,\n",
       "   'TYPENAME2': nan})]"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hadobjd = hadobj.set_index('OBJECTID').to_dict('index')\n",
    "if not chready:\n",
    "    # building chains recursively\n",
    "    chains = [\n",
    "        get_adms_rec_rev([x],  hp, adobjp)\n",
    "        for x in tqdm(hadobj[hadobj['LEVEL'] == '10']['OBJECTID'].drop_duplicates())\n",
    "    ]\n",
    "    chains = [x for x in chains if x is not None]\n",
    "# save and clean\n",
    "hadobj.to_csv(f'{region}_hadobj.csv', index=False)\n",
    "cleanup(hadobj)\n",
    "[(k, v) for k, v in hadobjd.items()][:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>chain</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>(33238432, 447128, 444817, 95239113, 95239112,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>(81986147, 455404, 454228, 157924581, 442495)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>(20160323, 441258, 442636, 95239183, 442495)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>(17648737, 447454, 95239030, 442495)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>(19761418, 450371, 449406, 95239146, 95239143,...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                               chain\n",
       "0  (33238432, 447128, 444817, 95239113, 95239112,...\n",
       "1      (81986147, 455404, 454228, 157924581, 442495)\n",
       "2       (20160323, 441258, 442636, 95239183, 442495)\n",
       "3               (17648737, 447454, 95239030, 442495)\n",
       "4  (19761418, 450371, 449406, 95239146, 95239143,..."
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfch = pd.DataFrame()\n",
    "if not chready:\n",
    "    odd_chains = [\n",
    "        tuple(x)\n",
    "        for x in chains\n",
    "        if type(x[0]) == list\n",
    "    ]\n",
    "    odd_chains = [reduce_included(x) for x in odd_chains]\n",
    "    odd_chains = [x for x, y in odd_chains if y] + [z for x, y in odd_chains if not y for z in x]\n",
    "    chains = [\n",
    "        tuple(x)\n",
    "        for x in chains\n",
    "        if type(x[0]) != list\n",
    "    ] + odd_chains\n",
    "\n",
    "dfch['chain'] = list(set(chains))\n",
    "# cleanup(chains)\n",
    "dfch.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('13476701', '448314', '162031408', '442495'),\n",
       " ('102928317', '445172', '442679', '95239122', '95239121', '442495'),\n",
       " ('160940575', '445390', '443524', '162033520', '442495'),\n",
       " ('161958121', '446273', '162033520', '442495'),\n",
       " ('161980828', '446273', '162033520', '442495'),\n",
       " ('161931029', '444092', '162033520', '442495'),\n",
       " ('161932662', '444092', '162033520', '442495'),\n",
       " ('55789014', '438727', '439409', '95239186', '442495'),\n",
       " ('51396267', '440882', '442571', '95239028', '442495'),\n",
       " ('60239548', '447111', '448895', '95239184', '442495'),\n",
       " ('58727691', '447490', '448895', '95239184', '442495'),\n",
       " ('63070135', '448886', '448895', '95239184', '442495'),\n",
       " ('44115044', '450802', '448895', '95239184', '442495'),\n",
       " ('28763164', '446780', '447238', '95239184', '442495'),\n",
       " ('61465277', '446981', '447238', '95239184', '442495'),\n",
       " ('65878528', '447733', '447238', '95239184', '442495'),\n",
       " ('55582701', '448220', '447238', '95239184', '442495'),\n",
       " ('52172126', '449657', '447238', '95239184', '442495'),\n",
       " ('82982055', '440544', '442540', '95239186', '442495'),\n",
       " ('15187918', '450503', '447238', '95239184', '442495'),\n",
       " ('78180493', '442176', '442540', '95239186', '442495'),\n",
       " ('56226370', '442701', '442540', '95239186', '442495'),\n",
       " ('54472213', '449832', '448573', '157721083', '442495'),\n",
       " ('70173472', '448532', '448573', '157721083', '442495'),\n",
       " ('73522300', '449606', '449132', '157721083', '442495'),\n",
       " ('79925244', '449265', '448454', '157721083', '442495'),\n",
       " ('7486594', '441081', '442636', '95239183', '442495'),\n",
       " ('8710698', '440868', '442636', '95239183', '442495'),\n",
       " ('10650386', '438858', '442636', '95239183', '442495'),\n",
       " ('21564216', '442978', '442636', '95239183', '442495'),\n",
       " ('38876184', '440831', '442636', '95239183', '442495'),\n",
       " ('43325649', '438889', '442636', '95239183', '442495'),\n",
       " ('45688051', '439758', '442636', '95239183', '442495'),\n",
       " ('46691461', '441241', '442636', '95239183', '442495'),\n",
       " ('46721294', '441241', '442636', '95239183', '442495'),\n",
       " ('47553296', '443111', '442636', '95239183', '442495'),\n",
       " ('60448410', '441005', '442636', '95239183', '442495'),\n",
       " ('62992510', '441627', '442636', '95239183', '442495'),\n",
       " ('48013101', '444251', '95239173', '442495'),\n",
       " ('39488083', '443589', '95239173', '442495'),\n",
       " ('41095796', '447593', '447212', '95239173', '442495'),\n",
       " ('13410395', '447458', '95239173', '442495'),\n",
       " ('64254775', '449061', '449629', '157721083', '442495'),\n",
       " ('25730787', '448749', '448724', '157721083', '442495'),\n",
       " ('42187521', '452247', '448539', '157721083', '442495'),\n",
       " ('58265366', '452138', '448570', '157721083', '442495'),\n",
       " ('68017081', '449851', '448570', '157721083', '442495'),\n",
       " ('35611322', '450265', '452031', '157721083', '442495'),\n",
       " ('82476555', '448189', '449751', '157721083', '442495'),\n",
       " ('103195846', '447955', '447238', '95239184', '442495'),\n",
       " ('101829859', '448652', '446297', '95239113', '95239112', '442495'),\n",
       " ('101851554', '448653', '446512', '95239116', '95239112', '442495'),\n",
       " ('68192124', '449551', '451868', '157737607', '442495'),\n",
       " ('60071393', '450182', '450450', '157737607', '442495'),\n",
       " ('79058559', '446801', '157721129', '442495'),\n",
       " ('20125553', '443392', '95239139', '95239121', '442495'),\n",
       " ('34916834', '444521', '95239125', '95239121', '442495'),\n",
       " ('62659412', '443764', '444437', '95239134', '95239121', '442495'),\n",
       " ('60560599', '449857', '446334', '157721129', '442495'),\n",
       " ('57437532', '445341', '443569', '95239125', '95239121', '442495'),\n",
       " ('78804492', '444323', '95239133', '95239121', '442495'),\n",
       " ('31368928', '445457', '95239117', '95239112', '442495'),\n",
       " ('48933055', '444841', '95239133', '95239121', '442495'),\n",
       " ('67444570', '445622', '95239126', '95239121', '442495'),\n",
       " ('76260264', '446747', '95239141', '95239121', '442495'),\n",
       " ('21610742', '445387', '95239117', '95239112', '442495'),\n",
       " ('7750458', '447173', '95239113', '95239112', '442495'),\n",
       " ('36562502', '444514', '446496', '95239136', '95239121', '442495'),\n",
       " ('61769180', '444714', '446496', '95239136', '95239121', '442495'),\n",
       " ('18010095', '446846', '95239142', '95239121', '442495'),\n",
       " ('35899597', '444547', '445243', '95239133', '95239121', '442495'),\n",
       " ('8405096', '448654', '449959', '95239157', '95239148', '442495'),\n",
       " ('63979548', '448865', '95239146', '95239143', '442495'),\n",
       " ('48020085', '451323', '448051', '95239147', '95239143', '442495'),\n",
       " ('19760370', '450371', '449406', '95239146', '95239143', '442495'),\n",
       " ('24748863', '449815', '95239157', '95239148', '442495'),\n",
       " ('7804054', '450090', '449998', '95239144', '95239143', '442495'),\n",
       " ('1586458', '451604', '95239158', '95239148', '442495'),\n",
       " ('24317047', '447045', '447845', '95239120', '95239112', '442495'),\n",
       " ('65050003', '452509', '451637', '95239153', '95239148', '442495'),\n",
       " ('32353224', '449398', '95239152', '95239148', '442495'),\n",
       " ('84242768', '448592', '449676', '95239146', '95239143', '442495'),\n",
       " ('65323964', '449810', '450874', '95239156', '95239148', '442495'),\n",
       " ('60802789', '449654', '451401', '95239152', '95239148', '442495'),\n",
       " ('29936872', '451757', '450554', '95239154', '95239148', '442495'),\n",
       " ('33824017', '449695', '451108', '95239147', '95239143', '442495'),\n",
       " ('81055343', '448837', '449197', '95239144', '95239143', '442495'),\n",
       " ('45536416', '445339', '444817', '95239113', '95239112', '442495'),\n",
       " ('16808654', '450140', '450180', '95239154', '95239148', '442495'),\n",
       " ('29438714', '450298', '451401', '95239152', '95239148', '442495'),\n",
       " ('74196311', '451097', '451401', '95239152', '95239148', '442495'),\n",
       " ('19153566', '445224', '444817', '95239113', '95239112', '442495'),\n",
       " ('68707787', '450445', '447720', '95239146', '95239143', '442495'),\n",
       " ('61487134', '450094', '449197', '95239144', '95239143', '442495'),\n",
       " ('69701148', '443148', '442703', '95239123', '95239121', '442495'),\n",
       " ('34612288', '446585', '444817', '95239113', '95239112', '442495'),\n",
       " ('68636647', '445118', '442703', '95239123', '95239121', '442495'),\n",
       " ('22911271', '447294', '444817', '95239113', '95239112', '442495'),\n",
       " ('7928003', '450844', '449152', '157721129', '442495'),\n",
       " ('45196673', '447147', '444817', '95239113', '95239112', '442495'),\n",
       " ('56796107', '450034', '446679', '157721129', '442495'),\n",
       " ('33810475', '450190', '446844', '157721129', '442495'),\n",
       " ('57069009', '449426', '449122', '157721129', '442495'),\n",
       " ('70510071', '448126', '444817', '95239113', '95239112', '442495'),\n",
       " ('2640972', '448854', '157721129', '442495'),\n",
       " ('14033232', '445941', '442679', '95239122', '95239121', '442495'),\n",
       " ('102010923', '447739', '157721129', '442495'),\n",
       " ('3125086', '452030', '157744348', '442495'),\n",
       " ('32948690', '448334', '157744348', '442495'),\n",
       " ('31995317', '446741', '442679', '95239122', '95239121', '442495'),\n",
       " ('40603394', '448380', '157744348', '442495'),\n",
       " ('44183891', '447340', '442679', '95239122', '95239121', '442495'),\n",
       " ('15612313', '451154', '157744348', '442495'),\n",
       " ('15631602', '451154', '157744348', '442495'),\n",
       " ('20364220', '448191', '157721129', '442495'),\n",
       " ('62529324', '449862', '157721129', '442495'),\n",
       " ('15997314', '449803', '450050', '157721129', '442495'),\n",
       " ('64240379', '448609', '450050', '157721129', '442495'),\n",
       " ('76320446', '455517', '157735857', '442495'),\n",
       " ('47527149', '453928', '455147', '157735857', '442495'),\n",
       " ('26396071', '453528', '157721103', '442495'),\n",
       " ('69376116', '452470', '456192', '157721103', '442495'),\n",
       " ('54221186', '456239', '157721103', '442495'),\n",
       " ('70733084', '452231', '157721103', '442495'),\n",
       " ('40402424', '452716', '453092', '157721103', '442495'),\n",
       " ('40464144', '452716', '453092', '157721103', '442495'),\n",
       " ('59311438', '455956', '455422', '157735857', '442495'),\n",
       " ('31065119', '455432', '157721103', '442495'),\n",
       " ('74883917', '456597', '157721103', '442495'),\n",
       " ('34072605', '454591', '452672', '157721103', '442495'),\n",
       " ('21190266', '451356', '452667', '162030634', '442495'),\n",
       " ('51343989', '453727', '157721103', '442495'),\n",
       " ('53424113', '451143', '450678', '162030634', '442495'),\n",
       " ('54078001', '452450', '450678', '162030634', '442495'),\n",
       " ('77342138', '451024', '449969', '162030634', '442495'),\n",
       " ('46290676', '450485', '162030634', '442495'),\n",
       " ('17631618', '446158', '162033520', '442495'),\n",
       " ('28184688', '453556', '157721103', '442495'),\n",
       " ('13583652', '456485', '157721103', '442495'),\n",
       " ('76072063', '451986', '447361', '162031408', '442495'),\n",
       " ('54226867', '456801', '157721103', '442495'),\n",
       " ('38831230', '452602', '452864', '157721103', '442495'),\n",
       " ('28918050', '444711', '444562', '95239030', '442495'),\n",
       " ('6543851', '443414', '95239030', '442495'),\n",
       " ('33975845', '444024', '95239030', '442495'),\n",
       " ('46881140', '444629', '447166', '95239030', '442495'),\n",
       " ('48857695', '444109', '447166', '95239030', '442495'),\n",
       " ('7416971', '445135', '95239030', '442495'),\n",
       " ('37471397', '444236', '447531', '95239030', '442495'),\n",
       " ('23759531', '454460', '454951', '157721103', '442495'),\n",
       " ('29530428', '454407', '454951', '157721103', '442495'),\n",
       " ('33208184', '455438', '454951', '157721103', '442495'),\n",
       " ('64436593', '452944', '157721103', '442495'),\n",
       " ('99946135', '446946', '444817', '95239113', '95239112', '442495'),\n",
       " ('1498514', '446552', '444755', '95239082', '442495'),\n",
       " ('30547707', '444107', '444755', '95239082', '442495'),\n",
       " ('79568663', '444771', '95239084', '95239082', '442495'),\n",
       " ('63027750', '443912', '95239082', '442495'),\n",
       " ('18098614', '443572', '95239082', '442495'),\n",
       " ('36210982', '448010', '445526', '95239082', '442495'),\n",
       " ('18389269', '444429', '445734', '95239082', '442495'),\n",
       " ('50494951', '443891', '444665', '95239082', '442495'),\n",
       " ('61983182', '444621', '444665', '95239082', '442495'),\n",
       " ('76408155', '448650', '449712', '95239149', '95239148', '442495'),\n",
       " ('83800099', '452017', '449712', '95239149', '95239148', '442495'),\n",
       " ('101175001', '452553', '449712', '95239149', '95239148', '442495'),\n",
       " ('102332396', '442626', '438843', '95239183', '442495'),\n",
       " ('17201858', '454356', '157924581', '442495'),\n",
       " ('4097212', '452591', '157924581', '442495'),\n",
       " ('76836885', '443741', '95239089', '442495'),\n",
       " ('75559987', '447729', '95239089', '442495'),\n",
       " ('70016142', '445104', '95239089', '442495'),\n",
       " ('37340945', '446235', '95239095', '95239089', '442495'),\n",
       " ('47015342', '446201', '95239089', '442495'),\n",
       " ('26193384', '444895', '95239089', '442495'),\n",
       " ('79184676', '447738', '444311', '95239089', '442495'),\n",
       " ('82624586', '446762', '95239089', '442495'),\n",
       " ('50250140', '445398', '95239089', '442495'),\n",
       " ('54406734', '443704', '95239089', '442495'),\n",
       " ('42903992', '447556', '445781', '95239089', '442495'),\n",
       " ('61719665', '448007', '445781', '95239089', '442495'),\n",
       " ('31000645', '447218', '443223', '95239089', '442495'),\n",
       " ('81830839', '445301', '444667', '95239089', '442495'),\n",
       " ('67297710', '445601', '446092', '95239089', '442495'),\n",
       " ('21534385', '454793', '451015', '95239067', '442495'),\n",
       " ('26585222', '453557', '451015', '95239067', '442495'),\n",
       " ('47889662', '455335', '452373', '95239067', '442495'),\n",
       " ('27316701', '451133', '450330', '95239067', '442495'),\n",
       " ('79775673', '454266', '454826', '95239067', '442495'),\n",
       " ('53847697', '454663', '453497', '95239067', '442495'),\n",
       " ('50139760', '454827', '450952', '95239067', '442495'),\n",
       " ('62953824', '452569', '95239067', '442495'),\n",
       " ('81170170', '452862', '454011', '95239067', '442495'),\n",
       " ('25327398', '453838', '450187', '95239067', '442495'),\n",
       " ('103487170', '100943162', '442614', '95239186', '442495'),\n",
       " ('70191738', '449993', '162030634', '442495'),\n",
       " ('24723026', '450720', '162030634', '442495'),\n",
       " ('35057356', '450432', '162030634', '442495'),\n",
       " ('64466205', '449399', '162030634', '442495'),\n",
       " ('71174245', '451525', '450388', '162030634', '442495'),\n",
       " ('27040905', '450808', '451151', '162030634', '442495'),\n",
       " ('77261028', '449376', '451750', '162030634', '442495'),\n",
       " ('66277017', '453560', '451750', '162030634', '442495'),\n",
       " ('3742324', '451828', '162030634', '442495'),\n",
       " ('4818255', '451054', '450774', '162030634', '442495'),\n",
       " ('29530091', '453296', '449633', '162030634', '442495'),\n",
       " ('70556015', '441791', '162033520', '442495'),\n",
       " ('82028334', '445951', '443922', '162033520', '442495'),\n",
       " ('49980174', '452317', '162030634', '442495'),\n",
       " ('162051414', '100247822', '442650', '95239186', '442495'),\n",
       " ('159131021', '445270', '162033520', '442495'),\n",
       " ('30115888', '442289', '444100', '162033520', '442495'),\n",
       " ('103730608', '442020', '442762', '162033520', '442495'),\n",
       " ('78479724', '453426', '452741', '162030634', '442495'),\n",
       " ('35753000', '444618', '444957', '162033520', '442495'),\n",
       " ('73188727', '444649', '162033520', '442495'),\n",
       " ('76811856', '445463', '162033520', '442495'),\n",
       " ('81619057', '446022', '162033520', '442495'),\n",
       " ('47164247', '454313', '95239171', '95239159', '442495'),\n",
       " ('19320259', '443394', '162033520', '442495'),\n",
       " ('30954491', '444724', '162033520', '442495'),\n",
       " ('6416166', '453903', '451624', '157924581', '442495'),\n",
       " ('73579436', '455887', '451624', '157924581', '442495'),\n",
       " ('102416004', '454751', '451624', '157924581', '442495'),\n",
       " ('38265437', '453590', '451463', '157924581', '442495'),\n",
       " ('77251639', '452962', '157924581', '442495'),\n",
       " ('68094677', '455332', '451382', '157924581', '442495'),\n",
       " ('72434818', '452906', '454228', '157924581', '442495'),\n",
       " ('81974031', '455404', '454228', '157924581', '442495'),\n",
       " ('96354712', '455015', '454228', '157924581', '442495'),\n",
       " ('5263209', '454872', '452887', '157924581', '442495'),\n",
       " ('27873523', '455685', '453077', '157924581', '442495'),\n",
       " ('58785640', '454679', '157924581', '442495'),\n",
       " ('76598637', '452556', '157924581', '442495'),\n",
       " ('63063074', '455160', '157924581', '442495'),\n",
       " ('58551474', '456396', '451855', '157924581', '442495'),\n",
       " ('46987113', '452898', '455177', '157924581', '442495'),\n",
       " ('21556099', '452405', '452084', '157924581', '442495'),\n",
       " ('49886111', '455546', '455108', '157924581', '442495'),\n",
       " ('160474178', '96064328', '95239028', '442495'),\n",
       " ('160931043', '455462', '454553', '95239067', '442495'),\n",
       " ('161561250', '453479', '455570', '157924581', '442495'),\n",
       " ('161813133', '161457794', '442221', '442571', '95239028', '442495'),\n",
       " ('75968070', '447940', '447620', '162031408', '442495'),\n",
       " ('75974395', '447940', '447620', '162031408', '442495'),\n",
       " ('81625759', '452089', '449387', '162031408', '442495'),\n",
       " ('83761374', '452750', '162031408', '442495'),\n",
       " ('70183362', '451269', '162031408', '442495'),\n",
       " ('36910144', '448556', '162031408', '442495'),\n",
       " ('73333420', '445342', '162033520', '442495'),\n",
       " ('68403778', '443153', '162033520', '442495'),\n",
       " ('161365212', '444069', '444060', '162033520', '442495'),\n",
       " ('158725797', '443897', '162033520', '442495'),\n",
       " ('159216193', '443488', '441662', '162033520', '442495'),\n",
       " ('161669092', '442494', '162033520', '442495'),\n",
       " ('160245349', '444071', '162033520', '442495'),\n",
       " ('162357218', '442888', '162033520', '442495'),\n",
       " ('5843817', '442694', '438540', '95239186', '442495'),\n",
       " ('25642626', '438723', '442594', '95239057', '442495'),\n",
       " ('27829166', '449947', '448895', '95239184', '442495'),\n",
       " ('66428079', '439477', '442540', '95239186', '442495'),\n",
       " ('26312825', '448540', '447238', '95239184', '442495'),\n",
       " ('52974619', '448023', '447238', '95239184', '442495'),\n",
       " ('29163301', '440657', '442540', '95239186', '442495'),\n",
       " ('56745155', '449847', '447238', '95239184', '442495'),\n",
       " ('27163630', '442428', '442540', '95239186', '442495'),\n",
       " ('102991180', '442766', '442636', '95239183', '442495'),\n",
       " ('97890943', '444960', '444779', '95239141', '95239121', '442495'),\n",
       " ('26570051', '450055', '448573', '157721083', '442495'),\n",
       " ('52861952', '449252', '448573', '157721083', '442495'),\n",
       " ('44631186', '448457', '449397', '157721083', '442495'),\n",
       " ('2704783', '450937', '451564', '157721083', '442495'),\n",
       " ('5211208', '442809', '442636', '95239183', '442495'),\n",
       " ('10898777', '439655', '442636', '95239183', '442495'),\n",
       " ('11353336', '438735', '442636', '95239183', '442495'),\n",
       " ('16060503', '438930', '442636', '95239183', '442495'),\n",
       " ('17150093', '439111', '442636', '95239183', '442495'),\n",
       " ('20136116', '441258', '442636', '95239183', '442495'),\n",
       " ('22800403', '441030', '442636', '95239183', '442495'),\n",
       " ('23331230', '441030', '442636', '95239183', '442495'),\n",
       " ('25522495', '440801', '442636', '95239183', '442495'),\n",
       " ('27573365', '439359', '442636', '95239183', '442495'),\n",
       " ('27686548', '439359', '442636', '95239183', '442495'),\n",
       " ('27706130', '439359', '442636', '95239183', '442495'),\n",
       " ('27754209', '439359', '442636', '95239183', '442495'),\n",
       " ('30352805', '441849', '442636', '95239183', '442495'),\n",
       " ('45722438', '442766', '442636', '95239183', '442495'),\n",
       " ('48369948', '440208', '442636', '95239183', '442495'),\n",
       " ('50190988', '439444', '442636', '95239183', '442495'),\n",
       " ('58732255', '442671', '442636', '95239183', '442495'),\n",
       " ('60683502', '438962', '442636', '95239183', '442495'),\n",
       " ('63890015', '441848', '442636', '95239183', '442495'),\n",
       " ('69712538', '439702', '442636', '95239183', '442495'),\n",
       " ('79578646', '439059', '442636', '95239183', '442495'),\n",
       " ('101776223', '447948', '447212', '95239173', '442495'),\n",
       " ('31721694', '444470', '95239173', '442495'),\n",
       " ('25006023', '451006', '448570', '157721083', '442495'),\n",
       " ('4950923', '448589', '449530', '157721083', '442495'),\n",
       " ('17314503', '448641', '450338', '157737607', '442495'),\n",
       " ('66941096', '449237', '450338', '157737607', '442495'),\n",
       " ('32824953', '451955', '449485', '157721083', '442495'),\n",
       " ('18795341', '449069', '451098', '157737607', '442495'),\n",
       " ('68246878', '448060', '451098', '157737607', '442495'),\n",
       " ('15581821', '450965', '452139', '157737607', '442495'),\n",
       " ('19480000', '448557', '452383', '157737607', '442495'),\n",
       " ('35532001', '451964', '157737607', '442495'),\n",
       " ('6058484', '448073', '450450', '157737607', '442495'),\n",
       " ('79067333', '446801', '157721129', '442495'),\n",
       " ('30386850', '444050', '443195', '95239134', '95239121', '442495'),\n",
       " ('36088866', '444485', '95239118', '95239112', '442495'),\n",
       " ('50031293', '445293', '95239128', '95239121', '442495'),\n",
       " ('41029211', '445614', '95239126', '95239121', '442495'),\n",
       " ('64288625', '447061', '442954', '95239142', '95239121', '442495'),\n",
       " ('25767037', '445822', '95239113', '95239112', '442495'),\n",
       " ('15318590', '445919', '95239113', '95239112', '442495'),\n",
       " ('37396501', '446235', '95239095', '95239089', '442495'),\n",
       " ('77723279', '447959', '95239147', '95239143', '442495'),\n",
       " ('28730546', '442866', '442679', '95239122', '95239121', '442495'),\n",
       " ('73265852', '443213', '446737', '95239139', '95239121', '442495'),\n",
       " ('7165141', '446819', '446512', '95239116', '95239112', '442495'),\n",
       " ('39674578', '450440', '95239157', '95239148', '442495'),\n",
       " ('24639036', '449815', '95239157', '95239148', '442495'),\n",
       " ('18830620', '450981', '95239158', '95239148', '442495'),\n",
       " ('15044470', '451120', '450756', '95239157', '95239148', '442495'),\n",
       " ('52312126', '450038', '449438', '95239158', '95239148', '442495'),\n",
       " ('69686827', '449202', '446512', '95239116', '95239112', '442495'),\n",
       " ('45542250', '445339', '444817', '95239113', '95239112', '442495'),\n",
       " ('40857186', '452692', '452010', '95239157', '95239148', '442495'),\n",
       " ('21453643', '443794', '442679', '95239122', '95239121', '442495'),\n",
       " ('14015360', '444985', '444817', '95239113', '95239112', '442495'),\n",
       " ('62852888', '451428', '450180', '95239154', '95239148', '442495'),\n",
       " ('42150136', '446095', '444817', '95239113', '95239112', '442495'),\n",
       " ('47174656', '443810', '442679', '95239122', '95239121', '442495'),\n",
       " ('3210763', '452641', '451401', '95239152', '95239148', '442495'),\n",
       " ('29236289', '446127', '444817', '95239113', '95239112', '442495'),\n",
       " ('42491600', '444154', '442679', '95239122', '95239121', '442495'),\n",
       " ('41148948', '447242', '444817', '95239113', '95239112', '442495'),\n",
       " ('83012817', '446240', '442703', '95239123', '95239121', '442495'),\n",
       " ('25310974', '444885', '442679', '95239122', '95239121', '442495'),\n",
       " ('47523299', '446830', '447293', '157721129', '442495'),\n",
       " ('20251490', '447819', '157721129', '442495'),\n",
       " ('18724256', '450610', '157721129', '442495'),\n",
       " ('6515330', '451405', '157744348', '442495'),\n",
       " ('80132729', '447398', '442679', '95239122', '95239121', '442495'),\n",
       " ('15640428', '451154', '157744348', '442495'),\n",
       " ('38711786', '451044', '157744348', '442495'),\n",
       " ('30803034', '448274', '157721129', '442495'),\n",
       " ('83376625', '449437', '450050', '157721129', '442495'),\n",
       " ('103838622', '439779', '442521', '95239029', '442495'),\n",
       " ('10013470', '454834', '157735857', '442495'),\n",
       " ('18884902', '456567', '454033', '157735857', '442495'),\n",
       " ('25343320', '455551', '456024', '157735857', '442495'),\n",
       " ('26110658', '456222', '455147', '157735857', '442495'),\n",
       " ('2236783', '456761', '157735857', '442495'),\n",
       " ('2248858', '456761', '157735857', '442495'),\n",
       " ('20538734', '456891', '157721103', '442495'),\n",
       " ('14279108', '454509', '157721103', '442495'),\n",
       " ('65102994', '453540', '456412', '157721103', '442495'),\n",
       " ('36906571', '452502', '157721103', '442495'),\n",
       " ('83396571', '452730', '157721103', '442495'),\n",
       " ('22050762', '453468', '452672', '157721103', '442495'),\n",
       " ('21777836', '451211', '450205', '162030634', '442495'),\n",
       " ('37349068', '455672', '456642', '157721103', '442495'),\n",
       " ('101185952', '454030', '157721103', '442495'),\n",
       " ('3291783', '455519', '157721103', '442495'),\n",
       " ('11560810', '450923', '450678', '162030634', '442495'),\n",
       " ('16129663', '457086', '157721103', '442495'),\n",
       " ('23050904', '451022', '447361', '162031408', '442495'),\n",
       " ('61576043', '444105', '95239030', '442495'),\n",
       " ('70530067', '446630', '444721', '95239030', '442495'),\n",
       " ('24333703', '444599', '95239030', '442495'),\n",
       " ('14388403', '446163', '95239030', '442495'),\n",
       " ('81407837', '445871', '95239030', '442495'),\n",
       " ('63534439', '445249', '447166', '95239030', '442495'),\n",
       " ('75020872', '453647', '157721103', '442495'),\n",
       " ('70429464', '453039', '454951', '157721103', '442495'),\n",
       " ('73092831', '452581', '157721103', '442495'),\n",
       " ('17425372', '452824', '157721103', '442495'),\n",
       " ('65512415', '456083', '453772', '157721103', '442495'),\n",
       " ('56895641', '444477', '95239082', '442495'),\n",
       " ('66173202', '445079', '95239082', '442495'),\n",
       " ('52566803', '445178', '95239082', '442495'),\n",
       " ('2906823', '448030', '447794', '95239082', '442495'),\n",
       " ('39290692', '445378', '95239082', '442495'),\n",
       " ('20435992', '445630', '443759', '95239082', '442495'),\n",
       " ('25302295', '447857', '445889', '95239082', '442495'),\n",
       " ('58551031', '447068', '445052', '95239082', '442495'),\n",
       " ('6544113', '447919', '95239082', '442495'),\n",
       " ('10880117', '445412', '444665', '95239082', '442495'),\n",
       " ('26177091', '446417', '444665', '95239082', '442495'),\n",
       " ('35871900', '445242', '444665', '95239082', '442495'),\n",
       " ('51630947', '446363', '444665', '95239082', '442495'),\n",
       " ('73777915', '447915', '444665', '95239082', '442495'),\n",
       " ('5034850', '446885', '443867', '95239082', '442495'),\n",
       " ('6758168', '451943', '449712', '95239149', '95239148', '442495'),\n",
       " ('74710523', '448499', '449712', '95239149', '95239148', '442495'),\n",
       " ('75855464', '454311', '157924581', '442495'),\n",
       " ('102723847', '442547', '442540', '95239186', '442495'),\n",
       " ('20027159', '453140', '157924581', '442495'),\n",
       " ('76444557', '451581', '157924581', '442495'),\n",
       " ('35896747', '452799', '157924581', '442495'),\n",
       " ('80194428', '444209', '95239089', '442495'),\n",
       " ('4361774', '446134', '95239089', '442495'),\n",
       " ('53360817', '444940', '443397', '95239089', '442495'),\n",
       " ('53371339', '444940', '443397', '95239089', '442495'),\n",
       " ('58866481', '445285', '95239094', '95239089', '442495'),\n",
       " ('23021009', '447731', '447851', '95239089', '442495'),\n",
       " ('58090268', '443682', '95239089', '442495'),\n",
       " ('24195561', '446123', '95239089', '442495'),\n",
       " ('38759649', '445042', '95239089', '442495'),\n",
       " ('20855011', '445088', '95239173', '442495'),\n",
       " ('21166494', '443952', '95239089', '442495'),\n",
       " ('55680415', '447753', '445908', '95239089', '442495'),\n",
       " ('73347260', '445695', '445753', '95239089', '442495'),\n",
       " ('66462763', '453271', '454553', '95239067', '442495'),\n",
       " ('67494778', '450944', '454553', '95239067', '442495'),\n",
       " ('21291316', '453340', '452373', '95239067', '442495'),\n",
       " ('39256436', '452698', '452373', '95239067', '442495'),\n",
       " ('56666582', '450905', '452373', '95239067', '442495'),\n",
       " ('59680360', '453796', '452373', '95239067', '442495'),\n",
       " ('33241730', '451537', '450497', '95239067', '442495'),\n",
       " ('52409946', '451675', '95239067', '442495'),\n",
       " ('1813567', '453072', '95239067', '442495'),\n",
       " ('36481162', '453219', '454349', '95239067', '442495'),\n",
       " ('18085531', '452968', '95239067', '442495'),\n",
       " ('77251475', '453566', '452554', '95239067', '442495'),\n",
       " ('27585140', '455496', '450942', '95239067', '442495'),\n",
       " ('21421112', '451595', '95239067', '442495'),\n",
       " ('12422120', '451396', '454011', '95239067', '442495'),\n",
       " ('20408492', '454355', '450187', '95239067', '442495'),\n",
       " ('19233162', '452248', '450147', '162030634', '442495'),\n",
       " ('50116712', '452923', '451863', '162030634', '442495'),\n",
       " ('157250567', '439967', '442636', '95239183', '442495'),\n",
       " ('74009685', '449718', '450985', '162030634', '442495'),\n",
       " ('72009393', '452094', '449313', '162030634', '442495'),\n",
       " ('62805588', '450763', '450774', '162030634', '442495'),\n",
       " ('65160260', '453194', '450164', '162030634', '442495'),\n",
       " ('78973076', '451654', '162030634', '442495'),\n",
       " ('73519270', '444613', '162033520', '442495'),\n",
       " ('13985965', '446332', '443954', '162033520', '442495'),\n",
       " ('99145449', '444213', '443922', '162033520', '442495'),\n",
       " ('45386306', '450539', '162030634', '442495'),\n",
       " ('101642958', '443487', '441089', '162033520', '442495'),\n",
       " ('32326338', '450598', '449808', '162030634', '442495'),\n",
       " ('65783028', '443332', '162033520', '442495'),\n",
       " ('69006064', '443192', '162033520', '442495'),\n",
       " ('62538304', '440997', '162033520', '442495'),\n",
       " ('43815876', '452500', '95239167', '95239159', '442495'),\n",
       " ('14544953', '455272', '95239163', '95239159', '442495'),\n",
       " ('44570722', '453513', '157924581', '442495'),\n",
       " ('20428621', '448710', '95239056', '95239052', '442495'),\n",
       " ('66314583', '441529', '162033520', '442495'),\n",
       " ('66333502', '441529', '162033520', '442495'),\n",
       " ('160738554', '443494', '162033520', '442495'),\n",
       " ('52962081', '448629', '448674', '162031408', '442495'),\n",
       " ('34788288', '451302', '449030', '162031408', '442495'),\n",
       " ('44751390', '448215', '162031408', '442495'),\n",
       " ('47310267', '454870', '452348', '157924581', '442495'),\n",
       " ('8146792', '452237', '455570', '157924581', '442495'),\n",
       " ('17185233', '454356', '157924581', '442495'),\n",
       " ('60110449', '453726', '157924581', '442495'),\n",
       " ('35208677', '455461', '452216', '157924581', '442495'),\n",
       " ('60860613', '454864', '454875', '157924581', '442495'),\n",
       " ('75698804', '453235', '157924581', '442495'),\n",
       " ('16148575', '453018', '452887', '157924581', '442495'),\n",
       " ('44832591', '453337', '454644', '157924581', '442495'),\n",
       " ('100988401', '454375', '453855', '157924581', '442495'),\n",
       " ('55486283', '452148', '453938', '157924581', '442495'),\n",
       " ('72470950', '453495', '452791', '157924581', '442495'),\n",
       " ('72482852', '453495', '452791', '157924581', '442495'),\n",
       " ('26069226', '453544', '453203', '157924581', '442495'),\n",
       " ('48655918', '454734', '157924581', '442495'),\n",
       " ('159032393', '159031073', '98820957', '157721083', '442495'),\n",
       " ('159383965', '451444', '449197', '95239144', '95239143', '442495'),\n",
       " ('47695459', '450308', '162031408', '442495'),\n",
       " ('71116287', '448389', '162031408', '442495'),\n",
       " ('161380498', '439639', '442521', '95239029', '442495'),\n",
       " ('161588173', '454916', '453395', '157924581', '442495'),\n",
       " ('161792723', '439895', '442521', '95239029', '442495'),\n",
       " ('161834743', '439662', '442521', '95239029', '442495'),\n",
       " ('67906821', '448916', '95238984', '95238977', '442495'),\n",
       " ('13714994', '451402', '162031408', '442495'),\n",
       " ('68280172', '452088', '162031408', '442495'),\n",
       " ('10880440', '451083', '451330', '162031408', '442495'),\n",
       " ('32586476', '447774', '451330', '162031408', '442495'),\n",
       " ('80630097', '451317', '451330', '162031408', '442495'),\n",
       " ('24884229', '448377', '162031408', '442495'),\n",
       " ('8823046', '449486', '162031408', '442495'),\n",
       " ('2708595', '447968', '162031408', '442495'),\n",
       " ('26430699', '449945', '162031408', '442495'),\n",
       " ('49083931', '443413', '162033520', '442495'),\n",
       " ('160906775', '445308', '443524', '162033520', '442495'),\n",
       " ('160336219', '444839', '162033520', '442495'),\n",
       " ('36104161', '439704', '95239186', '442495'),\n",
       " ('55601496', '438727', '439409', '95239186', '442495'),\n",
       " ('162386501', '443631', '162033520', '442495'),\n",
       " ('79352437', '439662', '442521', '95239029', '442495'),\n",
       " ('74332042', '441546', '442594', '95239057', '442495'),\n",
       " ('39357074', '449371', '448895', '95239184', '442495'),\n",
       " ('61099313', '438637', '442540', '95239186', '442495'),\n",
       " ('42771738', '448661', '447238', '95239184', '442495'),\n",
       " ('44635630', '439772', '442540', '95239186', '442495'),\n",
       " ('78075233', '442176', '442540', '95239186', '442495'),\n",
       " ('5196432', '438532', '442636', '95239183', '442495'),\n",
       " ('4081195', '451992', '448573', '157721083', '442495'),\n",
       " ('36383735', '448873', '448573', '157721083', '442495'),\n",
       " ('56518944', '449825', '448573', '157721083', '442495'),\n",
       " ('18179422', '452169', '449675', '157721083', '442495'),\n",
       " ('3472859', '441440', '442636', '95239183', '442495'),\n",
       " ('7545747', '442080', '442636', '95239183', '442495'),\n",
       " ('9708048', '441174', '442636', '95239183', '442495'),\n",
       " ('10271467', '443018', '442636', '95239183', '442495'),\n",
       " ('10559178', '441300', '442636', '95239183', '442495'),\n",
       " ('11861604', '439326', '442636', '95239183', '442495'),\n",
       " ('14257078', '439442', '442636', '95239183', '442495'),\n",
       " ('15055243', '440291', '442636', '95239183', '442495'),\n",
       " ('16010755', '438798', '442636', '95239183', '442495'),\n",
       " ('17109183', '443266', '442636', '95239183', '442495'),\n",
       " ('20063952', '441258', '442636', '95239183', '442495'),\n",
       " ('20067451', '441258', '442636', '95239183', '442495'),\n",
       " ('24417462', '439120', '442636', '95239183', '442495'),\n",
       " ('27707714', '443289', '442636', '95239183', '442495'),\n",
       " ('33957150', '442755', '442636', '95239183', '442495'),\n",
       " ('34639173', '439932', '442636', '95239183', '442495'),\n",
       " ('45168541', '442362', '442636', '95239183', '442495'),\n",
       " ('57011159', '439440', '442636', '95239183', '442495'),\n",
       " ('64491625', '439165', '442636', '95239183', '442495'),\n",
       " ('67846475', '440545', '442636', '95239183', '442495'),\n",
       " ('61244673', '443653', '95239173', '442495'),\n",
       " ('62055529', '444922', '446722', '95239173', '442495'),\n",
       " ('42639118', '445716', '443923', '95239173', '442495'),\n",
       " ('34827991', '448110', '444070', '95239173', '442495'),\n",
       " ('61836598', '443880', '447212', '95239173', '442495'),\n",
       " ('5908314', '451821', '450510', '157721083', '442495'),\n",
       " ('77085328', '451661', '448625', '157721083', '442495'),\n",
       " ('18110476', '451158', '451395', '157737607', '442495'),\n",
       " ('11939868', '452202', '157737607', '442495'),\n",
       " ('56786359', '443587', '443352', '95239129', '95239121', '442495'),\n",
       " ('60164027', '443069', '95239141', '95239121', '442495'),\n",
       " ('77948616', '447965', '444525', '95239115', '95239112', '442495'),\n",
       " ('13350263', '447877', '446334', '157721129', '442495'),\n",
       " ('3112902', '443329', '442950', '95239139', '95239121', '442495'),\n",
       " ('1656168', '446036', '95239134', '95239121', '442495'),\n",
       " ('2603296', '443144', '444494', '95239124', '95239121', '442495'),\n",
       " ('67029952', '445927', '95239126', '95239121', '442495'),\n",
       " ('4955722', '443857', '446496', '95239136', '95239121', '442495'),\n",
       " ('9728006', '445328', '95239120', '95239112', '442495'),\n",
       " ('43611135', '444796', '445039', '95239132', '95239121', '442495'),\n",
       " ('58193342', '445982', '95239139', '95239121', '442495'),\n",
       " ('17151633', '443898', '445243', '95239133', '95239121', '442495'),\n",
       " ('1781314', '446312', '445039', '95239132', '95239121', '442495'),\n",
       " ('43538579', '448403', '449406', '95239146', '95239143', '442495'),\n",
       " ('21291321', '448761', '157721129', '442495'),\n",
       " ('80242526', '448551', '449896', '95239156', '95239148', '442495'),\n",
       " ('70887468', '450066', '95239158', '95239148', '442495'),\n",
       " ('78543600', '448366', '448062', '95239115', '95239112', '442495'),\n",
       " ('43784447', '448922', '448151', '95239117', '95239112', '442495'),\n",
       " ('65697831', '448620', '451265', '95239158', '95239148', '442495'),\n",
       " ('72121229', '452639', '449752', '95239158', '95239148', '442495'),\n",
       " ('65052029', '452509', '451637', '95239153', '95239148', '442495'),\n",
       " ('36230708', '447859', '449197', '95239144', '95239143', '442495'),\n",
       " ('48493416', '450593', '451483', '95239158', '95239148', '442495'),\n",
       " ('13213645', '452090', '452440', '95239158', '95239148', '442495'),\n",
       " ('7299111', '449104', '449712', '95239149', '95239148', '442495'),\n",
       " ('45206301', '444330', '442703', '95239123', '95239121', '442495'),\n",
       " ('10139626', '447685', '449152', '157721129', '442495'),\n",
       " ('83023242', '446240', '442703', '95239123', '95239121', '442495'),\n",
       " ('57656672', '445097', '442679', '95239122', '95239121', '442495'),\n",
       " ('12563737', '449361', '446679', '157721129', '442495'),\n",
       " ('24291010', '449988', '449712', '95239149', '95239148', '442495'),\n",
       " ('39324767', '447154', '447293', '157721129', '442495'),\n",
       " ('8755338', '447925', '444817', '95239113', '95239112', '442495'),\n",
       " ('52648357', '448312', '444817', '95239113', '95239112', '442495'),\n",
       " ('35209915', '450782', '449712', '95239149', '95239148', '442495'),\n",
       " ('7003158', '445504', '442679', '95239122', '95239121', '442495'),\n",
       " ('40098462', '452397', '449712', '95239149', '95239148', '442495'),\n",
       " ('36940802', '446102', '442679', '95239122', '95239121', '442495'),\n",
       " ('15647178', '450219', '448526', '157744348', '442495'),\n",
       " ('80213887', '447398', '442679', '95239122', '95239121', '442495'),\n",
       " ('80238774', '447398', '442679', '95239122', '95239121', '442495'),\n",
       " ('34329216', '449605', '448526', '157744348', '442495'),\n",
       " ('44068472', '449639', '448526', '157744348', '442495'),\n",
       " ('65267363', '449864', '448526', '157744348', '442495'),\n",
       " ('41920179', '450622', '447381', '157721129', '442495'),\n",
       " ('157390130', '451165', '450197', '157721129', '442495'),\n",
       " ('77023053', '448689', '157721129', '442495'),\n",
       " ('62401215', '449862', '157721129', '442495'),\n",
       " ('5706672', '448029', '450661', '157721129', '442495'),\n",
       " ('79454720', '446421', '157721129', '442495'),\n",
       " ('63448812', '455427', '157735857', '442495'),\n",
       " ('10041781', '454834', '157735857', '442495'),\n",
       " ('18923536', '456567', '454033', '157735857', '442495'),\n",
       " ('50229648', '453400', '456024', '157735857', '442495'),\n",
       " ('84076546', '452211', '157721103', '442495'),\n",
       " ('47461327', '453255', '157721103', '442495'),\n",
       " ('100595833', '454789', '157721103', '442495'),\n",
       " ('26685429', '452529', '157721103', '442495'),\n",
       " ('1879554', '454197', '157721103', '442495'),\n",
       " ('11447147', '453588', '157721103', '442495'),\n",
       " ('21583708', '456696', '157735857', '442495'),\n",
       " ('71893809', '451289', '450205', '162030634', '442495'),\n",
       " ('50964696', '453727', '157721103', '442495'),\n",
       " ('36486471', '456709', '157721103', '442495'),\n",
       " ('36583655', '456709', '157721103', '442495'),\n",
       " ('38364374', '453615', '157721103', '442495'),\n",
       " ('69300042', '453561', '157721103', '442495'),\n",
       " ('77304663', '442009', '162033520', '442495'),\n",
       " ('16587224', '449936', '447361', '162031408', '442495'),\n",
       " ('23477398', '450350', '447361', '162031408', '442495'),\n",
       " ('66012531', '447676', '447361', '162031408', '442495'),\n",
       " ('78814807', '455659', '157721103', '442495'),\n",
       " ('83623852', '443646', '444562', '95239030', '442495'),\n",
       " ('57892833', '445552', '95239030', '442495'),\n",
       " ('72265607', '447759', '95239030', '442495'),\n",
       " ('26776158', '443482', '443811', '95239030', '442495'),\n",
       " ('36230107', '443889', '95239030', '442495'),\n",
       " ('35804359', '446032', '445605', '95239030', '442495'),\n",
       " ('17853927', '446415', '95239030', '442495'),\n",
       " ('78982827', '440885', '442521', '95239029', '442495'),\n",
       " ('3661375', '455773', '157721103', '442495'),\n",
       " ('13538783', '455200', '157721103', '442495'),\n",
       " ('99257814', '455200', '157721103', '442495'),\n",
       " ('1506430', '445016', '444562', '95239030', '442495'),\n",
       " ('41377117', '456564', '455171', '157721103', '442495'),\n",
       " ('29180011', '446207', '95239082', '442495'),\n",
       " ('3413782', '447688', '95239082', '442495'),\n",
       " ('12975372', '446825', '95239082', '442495'),\n",
       " ('20060549', '446663', '445286', '95239082', '442495'),\n",
       " ('20066861', '446663', '445286', '95239082', '442495'),\n",
       " ('99189883', '446380', '447075', '95239082', '442495'),\n",
       " ('12562718', '444044', '444261', '95239082', '442495'),\n",
       " ('31440492', '446656', '444924', '95239082', '442495'),\n",
       " ('21286159', '445811', '444308', '95239082', '442495'),\n",
       " ('32101010', '445861', '444665', '95239082', '442495'),\n",
       " ('68997018', '444369', '444665', '95239082', '442495'),\n",
       " ('6418530', '446803', '446185', '95239082', '442495'),\n",
       " ('2081387', '451613', '449712', '95239149', '95239148', '442495'),\n",
       " ('19385641', '451623', '449712', '95239149', '95239148', '442495'),\n",
       " ('23004216', '451561', '449712', '95239149', '95239148', '442495'),\n",
       " ('63557733', '449269', '449712', '95239149', '95239148', '442495'),\n",
       " ('22677003', '443739', '95239089', '442495'),\n",
       " ('52246634', '446810', '95239089', '442495'),\n",
       " ('26012560', '444895', '95239089', '442495'),\n",
       " ('83648726', '445789', '95239089', '442495'),\n",
       " ('14772852', '445864', '95239089', '442495'),\n",
       " ('2259342', '446897', '95239173', '442495'),\n",
       " ('72251640', '452115', '95239067', '442495'),\n",
       " ('26301130', '443461', '95239173', '442495'),\n",
       " ('21151382', '443952', '95239089', '442495'),\n",
       " ('45292516', '446300', '95239089', '442495'),\n",
       " ('19148830', '445725', '445030', '95239089', '442495'),\n",
       " ('11752685', '451274', '452373', '95239067', '442495'),\n",
       " ('11771027', '451274', '452373', '95239067', '442495'),\n",
       " ('24070613', '452831', '452373', '95239067', '442495'),\n",
       " ('42785444', '454216', '450330', '95239067', '442495'),\n",
       " ('63357157', '452355', '451112', '95239067', '442495'),\n",
       " ('36363353', '451517', '95239067', '442495'),\n",
       " ('24615407', '454402', '450952', '95239067', '442495'),\n",
       " ('104762556', '439559', '442521', '95239029', '442495'),\n",
       " ('45703787', '451967', '450926', '162030634', '442495'),\n",
       " ('64438626', '449399', '162030634', '442495'),\n",
       " ('64471482', '449399', '162030634', '442495'),\n",
       " ('10687798', '453233', '451750', '162030634', '442495'),\n",
       " ('38330053', '452978', '450774', '162030634', '442495'),\n",
       " ('33909557', '453168', '449633', '162030634', '442495'),\n",
       " ('68533391', '441820', '162033520', '442495'),\n",
       " ('66327207', '452446', '162030634', '442495'),\n",
       " ('45205214', '445270', '162033520', '442495'),\n",
       " ('29160249', '442998', '162033520', '442495'),\n",
       " ('66631389', '441631', '162033520', '442495'),\n",
       " ('39388156', '445658', '444385', '162033520', '442495'),\n",
       " ('157771933', '445221', '445407', '442817', '162033520', '442495'),\n",
       " ('160587424', '442476', '446280', '162033520', '442495'),\n",
       " ('52580058', '157861083', '444957', '162033520', '442495'),\n",
       " ('60028054', '443492', '162033520', '442495'),\n",
       " ('27170071', '445176', '162033520', '442495'),\n",
       " ('159538427', '445463', '162033520', '442495'),\n",
       " ('31422975', '443884', '162033520', '442495'),\n",
       " ('22529594', '454716', '95239167', '95239159', '442495'),\n",
       " ('49797281', '449908', '95239055', '95239052', '442495'),\n",
       " ('22460281', '446561', '95239056', '95239052', '442495'),\n",
       " ('66051776', '440855', '162033520', '442495'),\n",
       " ('66058570', '440855', '162033520', '442495'),\n",
       " ('79603470', '444346', '162033520', '442495'),\n",
       " ('79227375', '445497', '162033520', '442495'),\n",
       " ('71605670', '443218', '444221', '162033520', '442495'),\n",
       " ('158593478', '157785334', '104415987', '95239082', '442495'),\n",
       " ('27919181', '455467', '455570', '157924581', '442495'),\n",
       " ('38276890', '453590', '451463', '157924581', '442495'),\n",
       " ('4329270', '454520', '452922', '157924581', '442495'),\n",
       " ('76429984', '451581', '157924581', '442495'),\n",
       " ('15355786', '455656', '453855', '157924581', '442495'),\n",
       " ('24498714', '452344', '455006', '157924581', '442495'),\n",
       " ('66391043', '452963', '453627', '157924581', '442495'),\n",
       " ('63063710', '455160', '157924581', '442495'),\n",
       " ('18166024', '453682', '157924581', '442495'),\n",
       " ('56899963', '453522', '453152', '157924581', '442495'),\n",
       " ('159032636', '451929', '448573', '157721083', '442495'),\n",
       " ('27911881', '448722', '450191', '162031408', '442495'),\n",
       " ('161380160', '161313167', '161257382', '442594', '95239057', '442495'),\n",
       " ('48157508', '449477', '95238984', '95238977', '442495'),\n",
       " ('101787855', '452976', '95239046', '95239037', '442495'),\n",
       " ('4748841', '451202', '449387', '162031408', '442495'),\n",
       " ('74576282', '450119', '449387', '162031408', '442495'),\n",
       " ('74659461', '452441', '447832', '162031408', '442495'),\n",
       " ('16594383', '450853', '449683', '162030634', '442495'),\n",
       " ('27070741', '448468', '162031408', '442495'),\n",
       " ('162175437', '161457820', '442221', '442571', '95239028', '442495'),\n",
       " ('30848131', '438612', '95239186', '442495'),\n",
       " ('35854855', '450342', '450407', '95239157', '95239148', '442495'),\n",
       " ('49115879', '443413', '162033520', '442495'),\n",
       " ('158957757', '442717', '162033520', '442495'),\n",
       " ('161422165', '444152', '444060', '162033520', '442495'),\n",
       " ('161644509', '445912', '162033520', '442495'),\n",
       " ('50224861', '445531', '162033520', '442495'),\n",
       " ('161958108', '446273', '162033520', '442495'),\n",
       " ('100570672', '99976421', '162033520', '442495'),\n",
       " ('162356366', '161457826', '442221', '442571', '95239028', '442495'),\n",
       " ('55750236', '442310', '442594', '95239057', '442495'),\n",
       " ('37254276', '441023', '444730', '442594', '95239057', '442495'),\n",
       " ('56066429', '447744', '448895', '95239184', '442495'),\n",
       " ('45978434', '449149', '448895', '95239184', '442495'),\n",
       " ('47157408', '447026', '447238', '95239184', '442495'),\n",
       " ('76949578', '447492', '447238', '95239184', '442495'),\n",
       " ('80514022', '447112', '447238', '95239184', '442495'),\n",
       " ('55521556', '449996', '447238', '95239184', '442495'),\n",
       " ('29382944', '450969', '447238', '95239184', '442495'),\n",
       " ('37893257', '441296', '442540', '95239186', '442495'),\n",
       " ('76065760', '442860', '442540', '95239186', '442495'),\n",
       " ('35670051', '443072', '442540', '95239186', '442495'),\n",
       " ('15974919', '440356', '442636', '95239183', '442495'),\n",
       " ('18315730', '451928', '448573', '157721083', '442495'),\n",
       " ('20003743', '450082', '448573', '157721083', '442495'),\n",
       " ('78380178', '450198', '448573', '157721083', '442495'),\n",
       " ('5336087', '439678', '442636', '95239183', '442495'),\n",
       " ('25449047', '440801', '442636', '95239183', '442495'),\n",
       " ('27771453', '439359', '442636', '95239183', '442495'),\n",
       " ('38713948', '440079', '442636', '95239183', '442495'),\n",
       " ('38747226', '440831', '442636', '95239183', '442495'),\n",
       " ('42329110', '443282', '442636', '95239183', '442495'),\n",
       " ('47456364', '443111', '442636', '95239183', '442495'),\n",
       " ('56135713', '441665', '442636', '95239183', '442495'),\n",
       " ('67770208', '441220', '442636', '95239183', '442495'),\n",
       " ('73811956', '439117', '442636', '95239183', '442495'),\n",
       " ('48838844', '443693', '95239173', '442495'),\n",
       " ('3300542', '444831', '95239173', '442495'),\n",
       " ('83027348', '445108', '443997', '95239173', '442495'),\n",
       " ('5780724', '447665', '95239173', '442495'),\n",
       " ('83911334', '446523', '95239173', '442495'),\n",
       " ('71481013', '443590', '447212', '95239173', '442495'),\n",
       " ('76792688', '447049', '444742', '95239173', '442495'),\n",
       " ('100831106', '444174', '446849', '95239173', '442495'),\n",
       " ('33161340', '450860', '448625', '157721083', '442495'),\n",
       " ('33253157', '451749', '450338', '157737607', '442495'),\n",
       " ('54218973', '449618', '450623', '157737607', '442495'),\n",
       " ('12836653', '451547', '452383', '157737607', '442495'),\n",
       " ('18048740', '448398', '450450', '157737607', '442495'),\n",
       " ('20806476', '443822', '442818', '95239129', '95239121', '442495'),\n",
       " ('63754312', '443632', '95239134', '95239121', '442495'),\n",
       " ('81952763', '449615', '444612', '95239116', '95239112', '442495'),\n",
       " ('47931993', '447560', '442818', '95239129', '95239121', '442495'),\n",
       " ('19946434', '443352', '95239129', '95239121', '442495'),\n",
       " ('53134952', '443013', '95239134', '95239121', '442495'),\n",
       " ('11903220', '442950', '95239139', '95239121', '442495'),\n",
       " ('66740423', '445907', '444437', '95239134', '95239121', '442495'),\n",
       " ('81867860', '446128', '95239135', '95239121', '442495'),\n",
       " ('27828605', '443426', '444779', '95239141', '95239121', '442495'),\n",
       " ('44025460', '443816', '95239133', '95239121', '442495'),\n",
       " ('68348301', '446947', '443569', '95239125', '95239121', '442495'),\n",
       " ('83746107', '444975', '95239126', '95239121', '442495'),\n",
       " ('65564144', '445578', '95239139', '95239121', '442495'),\n",
       " ('17425051', '443429', '445828', '95239124', '95239121', '442495'),\n",
       " ('18009700', '446846', '95239142', '95239121', '442495'),\n",
       " ('55310060', '448241', '95239120', '95239112', '442495'),\n",
       " ('73488709', '450297', '95239158', '95239148', '442495'),\n",
       " ('55884922', '445684', '446496', '95239136', '95239121', '442495'),\n",
       " ('44608835', '450179', '449121', '95239156', '95239148', '442495'),\n",
       " ('27717584', '449301', '95239157', '95239148', '442495'),\n",
       " ('77546165', '447232', '446512', '95239116', '95239112', '442495'),\n",
       " ('31342937', '449458', '451483', '95239158', '95239148', '442495'),\n",
       " ('53737146', '448843', '449935', '95239154', '95239148', '442495'),\n",
       " ('36008199', '449514', '95239157', '95239148', '442495'),\n",
       " ('30070520', '446716', '445090', '95239119', '95239112', '442495'),\n",
       " ('23079704', '449169', '452055', '95239158', '95239148', '442495'),\n",
       " ('62937520', '451428', '450180', '95239154', '95239148', '442495'),\n",
       " ('77907363', '445924', '444817', '95239113', '95239112', '442495'),\n",
       " ('45241867', '444330', '442703', '95239123', '95239121', '442495'),\n",
       " ('71072337', '443755', '442679', '95239122', '95239121', '442495'),\n",
       " ('33843979', '446680', '444817', '95239113', '95239112', '442495'),\n",
       " ('30003251', '449624', '449712', '95239149', '95239148', '442495'),\n",
       " ('53569208', '447308', '444817', '95239113', '95239112', '442495'),\n",
       " ('72305190', '445005', '442703', '95239123', '95239121', '442495'),\n",
       " ('69639102', '445535', '442703', '95239123', '95239121', '442495'),\n",
       " ('81255509', '448262', '449152', '157721129', '442495'),\n",
       " ('55828373', '445621', '442703', '95239123', '95239121', '442495'),\n",
       " ('80284792', '446987', '444817', '95239113', '95239112', '442495'),\n",
       " ('24217043', '449988', '449712', '95239149', '95239148', '442495'),\n",
       " ('75335482', '447761', '446679', '157721129', '442495'),\n",
       " ('31220908', '450826', '447293', '157721129', '442495'),\n",
       " ('33860304', '446526', '157721129', '442495'),\n",
       " ('64406751', '447885', '449122', '157721129', '442495'),\n",
       " ('20711671', '445327', '442679', '95239122', '95239121', '442495'),\n",
       " ('73560890', '448533', '444817', '95239113', '95239112', '442495'),\n",
       " ('20334345', '448955', '444817', '95239113', '95239112', '442495'),\n",
       " ('16967311', '451255', '157744348', '442495'),\n",
       " ('77355465', '448459', '157744348', '442495'),\n",
       " ('44239090', '447340', '442679', '95239122', '95239121', '442495'),\n",
       " ('41751232', '449473', '448526', '157744348', '442495'),\n",
       " ('80334401', '448639', '448526', '157744348', '442495'),\n",
       " ('81408639', '449325', '450197', '157721129', '442495'),\n",
       " ('74539968', '446833', '450552', '157721129', '442495'),\n",
       " ('30082557', '449229', '450050', '157721129', '442495'),\n",
       " ('162549071', '446363', '444665', '95239082', '442495'),\n",
       " ('73925181', '452885', '454491', '157735857', '442495'),\n",
       " ('41142539', '454431', '456024', '157735857', '442495'),\n",
       " ('32613957', '455446', '157735857', '442495'),\n",
       " ('81160486', '456662', '455147', '157735857', '442495'),\n",
       " ('77799515', '452131', '157721103', '442495'),\n",
       " ('74297277', '452408', '157721103', '442495'),\n",
       " ('69853119', '456494', '157721103', '442495'),\n",
       " ('103503925', '455900', '157721103', '442495'),\n",
       " ('22441242', '452966', '455159', '157721103', '442495'),\n",
       " ('102273419', '456875', '455422', '157735857', '442495'),\n",
       " ('74884286', '456597', '157721103', '442495'),\n",
       " ('158223511', '452051', '447720', '95239146', '95239143', '442495'),\n",
       " ('21189865', '451356', '452667', '162030634', '442495'),\n",
       " ('5402965', '453427', '157721103', '442495'),\n",
       " ('54211904', '454814', '157721103', '442495'),\n",
       " ('11129838', '452527', '450678', '162030634', '442495'),\n",
       " ('57978022', '453852', '450678', '162030634', '442495'),\n",
       " ('54279733', '442697', '162033520', '442495'),\n",
       " ('48404164', '456400', '157721103', '442495'),\n",
       " ('17065333', '450904', '447361', '162031408', '442495'),\n",
       " ('17123716', '444165', '95239030', '442495'),\n",
       " ('79694520', '445272', '95239030', '442495'),\n",
       " ('26487701', '445386', '444721', '95239030', '442495'),\n",
       " ('75468735', '445549', '445605', '95239030', '442495'),\n",
       " ('102795487', '453210', '157721103', '442495'),\n",
       " ('20744536', '455382', '453772', '157721103', '442495'),\n",
       " ('1498399', '446552', '444755', '95239082', '442495'),\n",
       " ('49181729', '447584', '447791', '95239082', '442495'),\n",
       " ('44656843', '446472', '446792', '95239082', '442495'),\n",
       " ('5144682', '443768', '95239030', '442495'),\n",
       " ('20192865', '447210', '444665', '95239082', '442495'),\n",
       " ('26170503', '446417', '444665', '95239082', '442495'),\n",
       " ('18657203', '450603', '449712', '95239149', '95239148', '442495'),\n",
       " ('18659392', '450603', '449712', '95239149', '95239148', '442495'),\n",
       " ('31504057', '449982', '449712', '95239149', '95239148', '442495'),\n",
       " ('55618101', '452710', '449712', '95239149', '95239148', '442495'),\n",
       " ('72355968', '452510', '449712', '95239149', '95239148', '442495'),\n",
       " ('53565880', '452520', '157924581', '442495'),\n",
       " ('76603212', '452556', '157924581', '442495'),\n",
       " ('81949212', '454283', '157924581', '442495'),\n",
       " ('84084148', '452325', '453435', '95239075', '95239067', '442495'),\n",
       " ('5653006', '444496', '95239089', '442495'),\n",
       " ('41153163', '454195', '95239067', '442495'),\n",
       " ('44995417', '445318', '95239089', '442495'),\n",
       " ('29319764', '444640', '445781', '95239089', '442495'),\n",
       " ('12951676', '444353', '95239173', '442495'),\n",
       " ('27645606', '443477', '445030', '95239089', '442495'),\n",
       " ('1844784', '453182', '454553', '95239067', '442495'),\n",
       " ('9120617', '453665', '452373', '95239067', '442495'),\n",
       " ('17009532', '455314', '452373', '95239067', '442495'),\n",
       " ('57661807', '453563', '454826', '95239067', '442495'),\n",
       " ('26085821', '455315', '450497', '95239067', '442495'),\n",
       " ('78253108', '452829', '95239067', '442495'),\n",
       " ('30946790', '452798', '453220', '95239067', '442495'),\n",
       " ('7141616', '455277', '451555', '95239067', '442495'),\n",
       " ('57220732', '453454', '450558', '95239067', '442495'),\n",
       " ('68537960', '453747', '95239067', '442495'),\n",
       " ('17579724', '451563', '95239067', '442495'),\n",
       " ('63378186', '455560', '454011', '95239067', '442495'),\n",
       " ('79701725', '451789', '454011', '95239067', '442495'),\n",
       " ('61438994', '451345', '452230', '95239067', '442495'),\n",
       " ('15255478', '452644', '95239067', '442495'),\n",
       " ('70521454', '451445', '162030634', '442495'),\n",
       " ('24717699', '450720', '162030634', '442495'),\n",
       " ('52373538', '449738', '453093', '162030634', '442495'),\n",
       " ('64429300', '449474', '449266', '162030634', '442495'),\n",
       " ('32024897', '441365', '162033520', '442495'),\n",
       " ('65460655', '444290', '162033520', '442495'),\n",
       " ('69763822', '451970', '450589', '162030634', '442495'),\n",
       " ('51013991', '443995', '162033520', '442495'),\n",
       " ('66623215', '441631', '162033520', '442495'),\n",
       " ('6639320', '443314', '162033520', '442495'),\n",
       " ('102730172', '444957', '162033520', '442495'),\n",
       " ('47170400', '444971', '162033520', '442495'),\n",
       " ('57880589', '442052', '443110', '162033520', '442495'),\n",
       " ('65826267', '443332', '162033520', '442495'),\n",
       " ('71138883', '443688', '162033520', '442495'),\n",
       " ('57751361', '446564', '445463', '162033520', '442495'),\n",
       " ('84074492', '441694', '162033520', '442495'),\n",
       " ('82890859', '442520', '162033520', '442495'),\n",
       " ('61553342', '442851', '162033520', '442495'),\n",
       " ('5221821', '442942', '162033520', '442495'),\n",
       " ('63583405', '453764', '157735857', '442495'),\n",
       " ('158596153', '448439', '95239082', '442495'),\n",
       " ('13994578', '450473', '448674', '162031408', '442495'),\n",
       " ('4196763', '451259', '162031408', '442495'),\n",
       " ('44791902', '448215', '162031408', '442495'),\n",
       " ('46433599', '453546', '157924581', '442495'),\n",
       " ('56118279', '455012', '451624', '157924581', '442495'),\n",
       " ('61807172', '454751', '451624', '157924581', '442495'),\n",
       " ('73591536', '455887', '451624', '157924581', '442495'),\n",
       " ('76921984', '456163', '451624', '157924581', '442495'),\n",
       " ('3158786', '453272', '455570', '157924581', '442495'),\n",
       " ('36973557', '454648', '455570', '157924581', '442495'),\n",
       " ('102212236', '453272', '455570', '157924581', '442495'),\n",
       " ('83680139', '453102', '157924581', '442495'),\n",
       " ('79918648', '455564', '453395', '157924581', '442495'),\n",
       " ('34526922', '454170', '454283', '157924581', '442495'),\n",
       " ('19107552', '455268', '455177', '157924581', '442495'),\n",
       " ('82013628', '453455', '455177', '157924581', '442495'),\n",
       " ('73814085', '453810', '157924581', '442495'),\n",
       " ('159039434', '450166', '448573', '157721083', '442495'),\n",
       " ('159321258', '446981', '447238', '95239184', '442495'),\n",
       " ('159322135', '446572', '450197', '157721129', '442495'),\n",
       " ('160398485', '443971', '442703', '95239123', '95239121', '442495'),\n",
       " ('161359458', '442694', '438540', '95239186', '442495'),\n",
       " ('161380493', '439639', '442521', '95239029', '442495'),\n",
       " ('161382643', '440885', '442521', '95239029', '442495'),\n",
       " ('161426638', '447080', '445781', '95239089', '442495'),\n",
       " ('161476689', '440756', '442395', '442594', '95239057', '442495'),\n",
       " ('161555558', '453138', '454826', '95239067', '442495'),\n",
       " ('7765095', '450856', '449387', '162031408', '442495'),\n",
       " ('82809679', '448462', '162031408', '442495'),\n",
       " ('101928704', '446368', '445291', '444159', '162033520', '442495'),\n",
       " ('1839253', '449818', '162031408', '442495'),\n",
       " ('17210148', '448285', '162031408', '442495'),\n",
       " ('21213766', '450506', '162031408', '442495'),\n",
       " ('97647585', '447512', '444817', '95239113', '95239112', '442495'),\n",
       " ('160907471', '445472', '443524', '162033520', '442495'),\n",
       " ('160526085', '445667', '445124', '162033520', '442495'),\n",
       " ('161668058', '442494', '162033520', '442495'),\n",
       " ('160626482', '160478810', '444421', '162033520', '442495'),\n",
       " ('100570701', '99976421', '162033520', '442495'),\n",
       " ('27812886', '438977', '440453', '95239186', '442495'),\n",
       " ('83619914', '438610', '442594', '95239057', '442495'),\n",
       " ('53910665', '438867', '442594', '95239057', '442495'),\n",
       " ('10283164', '443169', '442594', '95239057', '442495'),\n",
       " ('6730391', '441522', '444730', '442594', '95239057', '442495'),\n",
       " ('83546073', '450654', '448895', '95239184', '442495'),\n",
       " ('66702053', '439477', '442540', '95239186', '442495'),\n",
       " ('37584376', '448421', '447238', '95239184', '442495'),\n",
       " ('64923716', '449890', '447238', '95239184', '442495'),\n",
       " ('51632257', '450398', '447238', '95239184', '442495'),\n",
       " ('2118251', '442399', '442636', '95239183', '442495'),\n",
       " ('3825301', '440111', '442636', '95239183', '442495'),\n",
       " ('4764298', '438995', '442636', '95239183', '442495'),\n",
       " ('12738557', '438604', '442636', '95239183', '442495'),\n",
       " ('12887987', '440265', '442636', '95239183', '442495'),\n",
       " ('12903837', '441850', '442636', '95239183', '442495'),\n",
       " ('14243864', '439442', '442636', '95239183', '442495'),\n",
       " ('15315667', '440291', '442636', '95239183', '442495'),\n",
       " ('15962477', '438798', '442636', '95239183', '442495'),\n",
       " ('25431640', '441797', '442636', '95239183', '442495'),\n",
       " ('32838192', '440457', '442636', '95239183', '442495'),\n",
       " ('45948320', '440420', '442636', '95239183', '442495'),\n",
       " ('56937509', '441212', '442636', '95239183', '442495'),\n",
       " ('67805604', '441220', '442636', '95239183', '442495'),\n",
       " ('79583946', '441129', '442636', '95239183', '442495'),\n",
       " ('79942664', '439244', '442636', '95239183', '442495'),\n",
       " ('81806764', '440966', '442636', '95239183', '442495'),\n",
       " ('25981960', '446599', '95239173', '442495'),\n",
       " ('33963209', '446758', '95239173', '442495'),\n",
       " ('76222913', '444156', '95239173', '442495'),\n",
       " ('76234867', '444156', '95239173', '442495'),\n",
       " ('67122814', '448008', '443997', '95239173', '442495'),\n",
       " ('70217184', '444196', '443997', '95239173', '442495'),\n",
       " ('18225140', '445470', '443800', '95239173', '442495'),\n",
       " ('41272927', '444540', '447212', '95239173', '442495'),\n",
       " ('41246919', '444540', '447212', '95239173', '442495'),\n",
       " ('29192345', '446949', '447212', '95239173', '442495'),\n",
       " ('13555705', '445608', '444391', '95239173', '442495'),\n",
       " ('26372950', '443461', '95239173', '442495'),\n",
       " ('8152662', '444099', '447212', '95239173', '442495'),\n",
       " ('46149461', '448049', '447693', '95239173', '442495'),\n",
       " ('62117125', '446895', '447095', '95239173', '442495'),\n",
       " ('62108039', '446895', '447095', '95239173', '442495'),\n",
       " ('69232111', '451721', '449213', '157721083', '442495'),\n",
       " ('25960504', '450606', '448570', '157721083', '442495'),\n",
       " ('59888514', '442879', '95239122', '95239121', '442495'),\n",
       " ('14331259', '444173', '95239130', '95239121', '442495'),\n",
       " ('13220915', '444482', '95239126', '95239121', '442495'),\n",
       " ('26559508', '442613', '95239124', '95239121', '442495'),\n",
       " ('53134269', '443013', '95239134', '95239121', '442495'),\n",
       " ('79659807', '444608', '443917', '95239128', '95239121', '442495'),\n",
       " ('11905452', '442950', '95239139', '95239121', '442495'),\n",
       " ('84003958', '444418', '445267', '95239127', '95239121', '442495'),\n",
       " ('51980673', '445206', '95239137', '95239121', '442495'),\n",
       " ('56672438', '443697', '444564', '95239135', '95239121', '442495'),\n",
       " ('68332724', '446947', '443569', '95239125', '95239121', '442495'),\n",
       " ('79586024', '446510', '446459', '95239139', '95239121', '442495'),\n",
       " ('55099116', '445701', '95239134', '95239121', '442495'),\n",
       " ('1480064', '446626', '95239128', '95239121', '442495'),\n",
       " ('25303412', '445197', '445087', '95239127', '95239121', '442495'),\n",
       " ('79169806', '446887', '444437', '95239134', '95239121', '442495'),\n",
       " ('7338790', '445666', '95239120', '95239112', '442495'),\n",
       " ('46046287', '445012', '95239113', '95239112', '442495'),\n",
       " ('83717100', '443089', '442679', '95239122', '95239121', '442495'),\n",
       " ...]"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chains"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 242280/242280 [00:00<00:00, 285300.85it/s]\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>chain</th>\n",
       "      <th>levchain</th>\n",
       "      <th>10</th>\n",
       "      <th>9</th>\n",
       "      <th>8</th>\n",
       "      <th>7</th>\n",
       "      <th>6</th>\n",
       "      <th>5</th>\n",
       "      <th>4</th>\n",
       "      <th>3</th>\n",
       "      <th>2</th>\n",
       "      <th>1</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>(33238432, 447128, 444817, 95239113, 95239112,...</td>\n",
       "      <td>(10, 8, 6, 4, 3, 1)</td>\n",
       "      <td>33238432</td>\n",
       "      <td>None</td>\n",
       "      <td>447128</td>\n",
       "      <td>None</td>\n",
       "      <td>444817</td>\n",
       "      <td>None</td>\n",
       "      <td>95239113</td>\n",
       "      <td>95239112</td>\n",
       "      <td>None</td>\n",
       "      <td>442495</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>(81986147, 455404, 454228, 157924581, 442495)</td>\n",
       "      <td>(10, 8, 6, 3, 1)</td>\n",
       "      <td>81986147</td>\n",
       "      <td>None</td>\n",
       "      <td>455404</td>\n",
       "      <td>None</td>\n",
       "      <td>454228</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>157924581</td>\n",
       "      <td>None</td>\n",
       "      <td>442495</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>(20160323, 441258, 442636, 95239183, 442495)</td>\n",
       "      <td>(10, 8, 5, 3, 1)</td>\n",
       "      <td>20160323</td>\n",
       "      <td>None</td>\n",
       "      <td>441258</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>442636</td>\n",
       "      <td>None</td>\n",
       "      <td>95239183</td>\n",
       "      <td>None</td>\n",
       "      <td>442495</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>(17648737, 447454, 95239030, 442495)</td>\n",
       "      <td>(10, 6, 3, 1)</td>\n",
       "      <td>17648737</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>447454</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>95239030</td>\n",
       "      <td>None</td>\n",
       "      <td>442495</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>(19761418, 450371, 449406, 95239146, 95239143,...</td>\n",
       "      <td>(10, 8, 6, 4, 3, 1)</td>\n",
       "      <td>19761418</td>\n",
       "      <td>None</td>\n",
       "      <td>450371</td>\n",
       "      <td>None</td>\n",
       "      <td>449406</td>\n",
       "      <td>None</td>\n",
       "      <td>95239146</td>\n",
       "      <td>95239143</td>\n",
       "      <td>None</td>\n",
       "      <td>442495</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                               chain             levchain  \\\n",
       "0  (33238432, 447128, 444817, 95239113, 95239112,...  (10, 8, 6, 4, 3, 1)   \n",
       "1      (81986147, 455404, 454228, 157924581, 442495)     (10, 8, 6, 3, 1)   \n",
       "2       (20160323, 441258, 442636, 95239183, 442495)     (10, 8, 5, 3, 1)   \n",
       "3               (17648737, 447454, 95239030, 442495)        (10, 6, 3, 1)   \n",
       "4  (19761418, 450371, 449406, 95239146, 95239143,...  (10, 8, 6, 4, 3, 1)   \n",
       "\n",
       "         10     9       8     7       6       5         4          3     2  \\\n",
       "0  33238432  None  447128  None  444817    None  95239113   95239112  None   \n",
       "1  81986147  None  455404  None  454228    None      None  157924581  None   \n",
       "2  20160323  None  441258  None    None  442636      None   95239183  None   \n",
       "3  17648737  None    None  None  447454    None      None   95239030  None   \n",
       "4  19761418  None  450371  None  449406    None  95239146   95239143  None   \n",
       "\n",
       "        1  \n",
       "0  442495  \n",
       "1  442495  \n",
       "2  442495  \n",
       "3  442495  \n",
       "4  442495  "
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfch['levchain'] = [\n",
    "    tuple([hadobjd[y]['LEVEL'] for y in x if y != '0' and y in hadobjd])\n",
    "    for x in tqdm(dfch['chain'])\n",
    "]\n",
    "dat = [\n",
    "    {\n",
    "        m: l\n",
    "        for m, l in zip(x, y)\n",
    "    }\n",
    "    for x, y in zip(dfch['levchain'], dfch['chain'])\n",
    "]\n",
    "for i in range(10, 0, -1):\n",
    "    dfch[f'{i}'] = [\n",
    "        d[f'{i}']\n",
    "        if f'{i}' in d\n",
    "        else None\n",
    "        for d in dat\n",
    "    ]\n",
    "dfch.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 242280 entries, 0 to 242279\n",
      "Data columns (total 12 columns):\n",
      " #   Column    Non-Null Count   Dtype \n",
      "---  ------    --------------   ----- \n",
      " 0   chain     242280 non-null  object\n",
      " 1   levchain  242280 non-null  object\n",
      " 2   10        242280 non-null  object\n",
      " 3   9         0 non-null       object\n",
      " 4   8         157247 non-null  object\n",
      " 5   7         12793 non-null   object\n",
      " 6   6         178035 non-null  object\n",
      " 7   5         55889 non-null   object\n",
      " 8   4         52147 non-null   object\n",
      " 9   3         242280 non-null  object\n",
      " 10  2         0 non-null       object\n",
      " 11  1         242280 non-null  object\n",
      "dtypes: object(12)\n",
      "memory usage: 22.2+ MB\n"
     ]
    }
   ],
   "source": [
    "dfch.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>levchain</th>\n",
       "      <th>10</th>\n",
       "      <th>9</th>\n",
       "      <th>8</th>\n",
       "      <th>7</th>\n",
       "      <th>6</th>\n",
       "      <th>5</th>\n",
       "      <th>4</th>\n",
       "      <th>3</th>\n",
       "      <th>2</th>\n",
       "      <th>1</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10-8-6-3-1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10-7-5-4-3-1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>10-8-7-4-3-1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>10-8-7-5-3-1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>10-7-3-1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       levchain  10  9  8  7  6  5  4  3  2  1\n",
       "0    10-8-6-3-1   1  0  1  0  1  0  0  1  0  1\n",
       "1  10-7-5-4-3-1   1  0  0  1  0  1  1  1  0  1\n",
       "2  10-8-7-4-3-1   1  0  1  1  0  0  1  1  0  1\n",
       "3  10-8-7-5-3-1   1  0  1  1  0  1  0  1  0  1\n",
       "4      10-7-3-1   1  0  0  1  0  0  0  1  0  1"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chl = list(set(dfch['levchain'].apply(lambda x: '-'.join(x))))\n",
    "df = pd.DataFrame()\n",
    "df['levchain'] = chl\n",
    "for i in range(10, 0, -1):\n",
    "    dat = [(f'{i}' in y.split('-')) * 1 for y in chl]\n",
    "    df[f'{i}'] = dat\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 19 entries, 0 to 18\n",
      "Data columns (total 11 columns):\n",
      " #   Column    Non-Null Count  Dtype \n",
      "---  ------    --------------  ----- \n",
      " 0   levchain  19 non-null     object\n",
      " 1   10        19 non-null     int64 \n",
      " 2   9         19 non-null     int64 \n",
      " 3   8         19 non-null     int64 \n",
      " 4   7         19 non-null     int64 \n",
      " 5   6         19 non-null     int64 \n",
      " 6   5         19 non-null     int64 \n",
      " 7   4         19 non-null     int64 \n",
      " 8   3         19 non-null     int64 \n",
      " 9   2         19 non-null     int64 \n",
      " 10  1         19 non-null     int64 \n",
      "dtypes: int64(10), object(1)\n",
      "memory usage: 1.8+ KB\n"
     ]
    }
   ],
   "source": [
    "df.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['10-8-6-3-1',\n",
       " '10-7-5-4-3-1',\n",
       " '10-8-7-4-3-1',\n",
       " '10-8-7-5-3-1',\n",
       " '10-7-3-1',\n",
       " '10-7-6-4-3-1',\n",
       " '10-8-4-3-1',\n",
       " '10-8-5-4-3-1',\n",
       " '10-8-7-3-1',\n",
       " '10-6-3-1',\n",
       " '10-8-3-1',\n",
       " '10-8-6-4-3-1',\n",
       " '10-7-6-3-1',\n",
       " '10-6-4-3-1',\n",
       " '10-8-5-3-1',\n",
       " '10-8-7-6-4-3-1',\n",
       " '10-8-7-6-3-1',\n",
       " '10-7-5-3-1',\n",
       " '10-7-4-3-1']"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>levchain</th>\n",
       "      <th>10</th>\n",
       "      <th>9</th>\n",
       "      <th>8</th>\n",
       "      <th>7</th>\n",
       "      <th>6</th>\n",
       "      <th>5</th>\n",
       "      <th>4</th>\n",
       "      <th>3</th>\n",
       "      <th>2</th>\n",
       "      <th>1</th>\n",
       "      <th>street</th>\n",
       "      <th>town</th>\n",
       "      <th>leftover</th>\n",
       "      <th>muni</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>(10, 8, 6, 3, 1)</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>(10, 7, 5, 4, 3, 1)</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "      <td>5</td>\n",
       "      <td>[4]</td>\n",
       "      <td>[3]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>(10, 8, 7, 4, 3, 1)</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>8</td>\n",
       "      <td>4</td>\n",
       "      <td>[7]</td>\n",
       "      <td>[3]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>(10, 8, 7, 5, 3, 1)</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "      <td>[7]</td>\n",
       "      <td>[3]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>(10, 7, 3, 1)</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "      <td>1</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              levchain  10  9  8  7  6  5  4  3  2  1 street town leftover  \\\n",
       "0     (10, 8, 6, 3, 1)   1  0  1  0  1  0  0  1  0  1      8    6       []   \n",
       "1  (10, 7, 5, 4, 3, 1)   1  0  0  1  0  1  1  1  0  1      7    5      [4]   \n",
       "2  (10, 8, 7, 4, 3, 1)   1  0  1  1  0  0  1  1  0  1      8    4      [7]   \n",
       "3  (10, 8, 7, 5, 3, 1)   1  0  1  1  0  1  0  1  0  1      8    5      [7]   \n",
       "4        (10, 7, 3, 1)   1  0  0  1  0  0  0  1  0  1      7    1       []   \n",
       "\n",
       "  muni  \n",
       "0  [3]  \n",
       "1  [3]  \n",
       "2  [3]  \n",
       "3  [3]  \n",
       "4  [3]  "
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lst = df.apply(get_town, axis=1)\n",
    "df['street'] = [x[0] for x in lst]\n",
    "df['town'] = [x[1] for x in lst]\n",
    "df['leftover'] = [x[2] for x in lst]\n",
    "df['muni'] = [x[3] for x in lst]\n",
    "df['levchain'] = df['levchain'].apply(lambda x: tuple(x.split('-')))\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0         (8, 6, [], [3])\n",
       "1        (7, 5, [4], [3])\n",
       "2        (8, 4, [7], [3])\n",
       "3        (8, 5, [7], [3])\n",
       "4         (7, 1, [], [3])\n",
       "5        (7, 6, [4], [3])\n",
       "6         (8, 4, [], [3])\n",
       "7        (8, 5, [4], [3])\n",
       "8         (8, 7, [], [3])\n",
       "9         (6, 1, [], [3])\n",
       "10        (8, 1, [], [3])\n",
       "11       (8, 6, [4], [3])\n",
       "12        (7, 6, [], [3])\n",
       "13        (6, 4, [], [3])\n",
       "14        (8, 5, [], [3])\n",
       "15    (8, 6, [7, 4], [3])\n",
       "16       (8, 6, [7], [3])\n",
       "17        (7, 5, [], [3])\n",
       "18        (7, 4, [], [3])\n",
       "dtype: object"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lst"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 19 entries, 0 to 18\n",
      "Data columns (total 15 columns):\n",
      " #   Column    Non-Null Count  Dtype \n",
      "---  ------    --------------  ----- \n",
      " 0   levchain  19 non-null     object\n",
      " 1   10        19 non-null     int64 \n",
      " 2   9         19 non-null     int64 \n",
      " 3   8         19 non-null     int64 \n",
      " 4   7         19 non-null     int64 \n",
      " 5   6         19 non-null     int64 \n",
      " 6   5         19 non-null     int64 \n",
      " 7   4         19 non-null     int64 \n",
      " 8   3         19 non-null     int64 \n",
      " 9   2         19 non-null     int64 \n",
      " 10  1         19 non-null     int64 \n",
      " 11  street    19 non-null     object\n",
      " 12  town      19 non-null     object\n",
      " 13  leftover  19 non-null     object\n",
      " 14  muni      19 non-null     object\n",
      "dtypes: int64(10), object(5)\n",
      "memory usage: 2.4+ KB\n"
     ]
    }
   ],
   "source": [
    "df.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>chain</th>\n",
       "      <th>levchain</th>\n",
       "      <th>10</th>\n",
       "      <th>9</th>\n",
       "      <th>8</th>\n",
       "      <th>7</th>\n",
       "      <th>6</th>\n",
       "      <th>5</th>\n",
       "      <th>4</th>\n",
       "      <th>3</th>\n",
       "      <th>2</th>\n",
       "      <th>1</th>\n",
       "      <th>street</th>\n",
       "      <th>town</th>\n",
       "      <th>leftover</th>\n",
       "      <th>muni</th>\n",
       "      <th>region</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>(33238432, 447128, 444817, 95239113, 95239112,...</td>\n",
       "      <td>(10, 8, 6, 4, 3, 1)</td>\n",
       "      <td>33238432</td>\n",
       "      <td>None</td>\n",
       "      <td>447128</td>\n",
       "      <td>None</td>\n",
       "      <td>444817</td>\n",
       "      <td>None</td>\n",
       "      <td>95239113</td>\n",
       "      <td>95239112</td>\n",
       "      <td>None</td>\n",
       "      <td>442495</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>[4]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>(81986147, 455404, 454228, 157924581, 442495)</td>\n",
       "      <td>(10, 8, 6, 3, 1)</td>\n",
       "      <td>81986147</td>\n",
       "      <td>None</td>\n",
       "      <td>455404</td>\n",
       "      <td>None</td>\n",
       "      <td>454228</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>157924581</td>\n",
       "      <td>None</td>\n",
       "      <td>442495</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>(20160323, 441258, 442636, 95239183, 442495)</td>\n",
       "      <td>(10, 8, 5, 3, 1)</td>\n",
       "      <td>20160323</td>\n",
       "      <td>None</td>\n",
       "      <td>441258</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>442636</td>\n",
       "      <td>None</td>\n",
       "      <td>95239183</td>\n",
       "      <td>None</td>\n",
       "      <td>442495</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>(17648737, 447454, 95239030, 442495)</td>\n",
       "      <td>(10, 6, 3, 1)</td>\n",
       "      <td>17648737</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>447454</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>95239030</td>\n",
       "      <td>None</td>\n",
       "      <td>442495</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>(19761418, 450371, 449406, 95239146, 95239143,...</td>\n",
       "      <td>(10, 8, 6, 4, 3, 1)</td>\n",
       "      <td>19761418</td>\n",
       "      <td>None</td>\n",
       "      <td>450371</td>\n",
       "      <td>None</td>\n",
       "      <td>449406</td>\n",
       "      <td>None</td>\n",
       "      <td>95239146</td>\n",
       "      <td>95239143</td>\n",
       "      <td>None</td>\n",
       "      <td>442495</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>[4]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                               chain             levchain  \\\n",
       "0  (33238432, 447128, 444817, 95239113, 95239112,...  (10, 8, 6, 4, 3, 1)   \n",
       "1      (81986147, 455404, 454228, 157924581, 442495)     (10, 8, 6, 3, 1)   \n",
       "2       (20160323, 441258, 442636, 95239183, 442495)     (10, 8, 5, 3, 1)   \n",
       "3               (17648737, 447454, 95239030, 442495)        (10, 6, 3, 1)   \n",
       "4  (19761418, 450371, 449406, 95239146, 95239143,...  (10, 8, 6, 4, 3, 1)   \n",
       "\n",
       "         10     9       8     7       6       5         4          3     2  \\\n",
       "0  33238432  None  447128  None  444817    None  95239113   95239112  None   \n",
       "1  81986147  None  455404  None  454228    None      None  157924581  None   \n",
       "2  20160323  None  441258  None    None  442636      None   95239183  None   \n",
       "3  17648737  None    None  None  447454    None      None   95239030  None   \n",
       "4  19761418  None  450371  None  449406    None  95239146   95239143  None   \n",
       "\n",
       "        1 street town leftover muni                                   region  \n",
       "0  442495      8    6      [4]  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "1  442495      8    6       []  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "2  442495      8    5       []  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "3  442495      6    1       []  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "4  442495      8    6      [4]  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  "
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfch = dfch.merge(df[['levchain', 'street', 'town', 'leftover', 'muni']], on='levchain')\n",
    "dfch['region'] = region\n",
    "dfch.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [],
   "source": [
    "# dfch[dfch['4'] == '95239078']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [],
   "source": [
    "dfch.to_csv(f'{region}_parsed_chains.csv', sep=';', index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>HOUSENUM</th>\n",
       "      <th>HOUSENUM1</th>\n",
       "      <th>HOUSENUM2</th>\n",
       "      <th>HOUSETYPE</th>\n",
       "      <th>HOUSETYPE1</th>\n",
       "      <th>HOUSETYPE2</th>\n",
       "      <th>ISACTIVE</th>\n",
       "      <th>ISACTUAL</th>\n",
       "      <th>LEVEL</th>\n",
       "      <th>LEVELNAME</th>\n",
       "      <th>...</th>\n",
       "      <th>NAME1</th>\n",
       "      <th>NAME2</th>\n",
       "      <th>OBJECTGUID</th>\n",
       "      <th>OBJECTID</th>\n",
       "      <th>TYPELONGNAME</th>\n",
       "      <th>TYPELONGNAME1</th>\n",
       "      <th>TYPELONGNAME2</th>\n",
       "      <th>TYPENAME</th>\n",
       "      <th>TYPENAME1</th>\n",
       "      <th>TYPENAME2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "      <td>Элемент планировочной структуры</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>425d519f-3636-41bd-ae7e-0c284911ada9</td>\n",
       "      <td>445407</td>\n",
       "      <td>Территория садоводческого некоммерческого това...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>тер. СНТ</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>Сельское/городское поселение</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>6621d717-388a-4533-9571-142c34a22acc</td>\n",
       "      <td>95239078</td>\n",
       "      <td>сельское поселение</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>с.п.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>Сельское/городское поселение</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>42b314b1-95a4-406d-89bd-d81fc316f69c</td>\n",
       "      <td>95239091</td>\n",
       "      <td>сельское поселение</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>с.п.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>Сельское/городское поселение</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9e0cb420-4511-48a0-bac1-966f6170bfc7</td>\n",
       "      <td>95239119</td>\n",
       "      <td>сельское поселение</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>с.п.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>Муниципальный район</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>413ad5f9-fb3d-431e-8619-0376df3e9f4b</td>\n",
       "      <td>95239186</td>\n",
       "      <td>Городской округ</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>г.о.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 21 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "  HOUSENUM HOUSENUM1 HOUSENUM2  HOUSETYPE  HOUSETYPE1  HOUSETYPE2  ISACTIVE  \\\n",
       "0      NaN       NaN       NaN        NaN         NaN         NaN         1   \n",
       "1      NaN       NaN       NaN        NaN         NaN         NaN         1   \n",
       "2      NaN       NaN       NaN        NaN         NaN         NaN         1   \n",
       "3      NaN       NaN       NaN        NaN         NaN         NaN         1   \n",
       "4      NaN       NaN       NaN        NaN         NaN         NaN         1   \n",
       "\n",
       "   ISACTUAL  LEVEL                        LEVELNAME  ... NAME1 NAME2  \\\n",
       "0         1      7  Элемент планировочной структуры  ...   NaN   NaN   \n",
       "1         1      4     Сельское/городское поселение  ...   NaN   NaN   \n",
       "2         1      4     Сельское/городское поселение  ...   NaN   NaN   \n",
       "3         1      4     Сельское/городское поселение  ...   NaN   NaN   \n",
       "4         1      3              Муниципальный район  ...   NaN   NaN   \n",
       "\n",
       "                             OBJECTGUID  OBJECTID  \\\n",
       "0  425d519f-3636-41bd-ae7e-0c284911ada9    445407   \n",
       "1  6621d717-388a-4533-9571-142c34a22acc  95239078   \n",
       "2  42b314b1-95a4-406d-89bd-d81fc316f69c  95239091   \n",
       "3  9e0cb420-4511-48a0-bac1-966f6170bfc7  95239119   \n",
       "4  413ad5f9-fb3d-431e-8619-0376df3e9f4b  95239186   \n",
       "\n",
       "                                        TYPELONGNAME TYPELONGNAME1  \\\n",
       "0  Территория садоводческого некоммерческого това...           NaN   \n",
       "1                                 сельское поселение           NaN   \n",
       "2                                 сельское поселение           NaN   \n",
       "3                                 сельское поселение           NaN   \n",
       "4                                    Городской округ           NaN   \n",
       "\n",
       "  TYPELONGNAME2  TYPENAME TYPENAME1 TYPENAME2  \n",
       "0           NaN  тер. СНТ       NaN       NaN  \n",
       "1           NaN      с.п.       NaN       NaN  \n",
       "2           NaN      с.п.       NaN       NaN  \n",
       "3           NaN      с.п.       NaN       NaN  \n",
       "4           NaN      г.о.       NaN       NaN  \n",
       "\n",
       "[5 rows x 21 columns]"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hadobj = pd.read_csv(f'{region}_hadobj.csv', sep=',', low_memory=False)\n",
    "hadobj.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 256541 entries, 0 to 256540\n",
      "Data columns (total 21 columns):\n",
      " #   Column         Non-Null Count   Dtype  \n",
      "---  ------         --------------   -----  \n",
      " 0   HOUSENUM       242303 non-null  object \n",
      " 1   HOUSENUM1      26228 non-null   object \n",
      " 2   HOUSENUM2      2328 non-null    object \n",
      " 3   HOUSETYPE      242303 non-null  float64\n",
      " 4   HOUSETYPE1     26228 non-null   float64\n",
      " 5   HOUSETYPE2     2328 non-null    float64\n",
      " 6   ISACTIVE       256541 non-null  int64  \n",
      " 7   ISACTUAL       256541 non-null  int64  \n",
      " 8   LEVEL          256541 non-null  int64  \n",
      " 9   LEVELNAME      256541 non-null  object \n",
      " 10  NAME           256541 non-null  object \n",
      " 11  NAME1          26228 non-null   object \n",
      " 12  NAME2          2328 non-null    object \n",
      " 13  OBJECTGUID     256541 non-null  object \n",
      " 14  OBJECTID       256541 non-null  int64  \n",
      " 15  TYPELONGNAME   256541 non-null  object \n",
      " 16  TYPELONGNAME1  26228 non-null   object \n",
      " 17  TYPELONGNAME2  2328 non-null    object \n",
      " 18  TYPENAME       256541 non-null  object \n",
      " 19  TYPENAME1      26228 non-null   object \n",
      " 20  TYPENAME2      2328 non-null    object \n",
      "dtypes: float64(3), int64(4), object(14)\n",
      "memory usage: 41.1+ MB\n"
     ]
    }
   ],
   "source": [
    "hadobj.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'445407'"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "for x in [\n",
    "          'OBJECTID', 'OBJECTGUID', 'HOUSENUM', 'HOUSENUM1',\n",
    "          'HOUSENUM2', 'LEVEL', 'NAME',\n",
    "          'TYPELONGNAME', 'TYPELONGNAME1', 'TYPELONGNAME2',\n",
    "          'TYPENAME', 'TYPENAME1', 'TYPENAME2']:\n",
    "    hadobj[x] = hadobj[x].apply(lambda y: str(y) if y == y else np.nan)\n",
    "hadobj['OBJECTID'].values[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 256541 entries, 0 to 256540\n",
      "Data columns (total 21 columns):\n",
      " #   Column         Non-Null Count   Dtype  \n",
      "---  ------         --------------   -----  \n",
      " 0   HOUSENUM       242303 non-null  object \n",
      " 1   HOUSENUM1      26228 non-null   object \n",
      " 2   HOUSENUM2      2328 non-null    object \n",
      " 3   HOUSETYPE      242303 non-null  float64\n",
      " 4   HOUSETYPE1     26228 non-null   float64\n",
      " 5   HOUSETYPE2     2328 non-null    float64\n",
      " 6   ISACTIVE       256541 non-null  int64  \n",
      " 7   ISACTUAL       256541 non-null  int64  \n",
      " 8   LEVEL          256541 non-null  object \n",
      " 9   LEVELNAME      256541 non-null  object \n",
      " 10  NAME           256541 non-null  object \n",
      " 11  NAME1          26228 non-null   object \n",
      " 12  NAME2          2328 non-null    object \n",
      " 13  OBJECTGUID     256541 non-null  object \n",
      " 14  OBJECTID       256541 non-null  object \n",
      " 15  TYPELONGNAME   256541 non-null  object \n",
      " 16  TYPELONGNAME1  26228 non-null   object \n",
      " 17  TYPELONGNAME2  2328 non-null    object \n",
      " 18  TYPENAME       256541 non-null  object \n",
      " 19  TYPENAME1      26228 non-null   object \n",
      " 20  TYPENAME2      2328 non-null    object \n",
      "dtypes: float64(3), int64(2), object(16)\n",
      "memory usage: 41.1+ MB\n"
     ]
    }
   ],
   "source": [
    "hadobj.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>chain</th>\n",
       "      <th>levchain</th>\n",
       "      <th>10</th>\n",
       "      <th>9</th>\n",
       "      <th>8</th>\n",
       "      <th>7</th>\n",
       "      <th>6</th>\n",
       "      <th>5</th>\n",
       "      <th>4</th>\n",
       "      <th>3</th>\n",
       "      <th>2</th>\n",
       "      <th>1</th>\n",
       "      <th>street</th>\n",
       "      <th>town</th>\n",
       "      <th>leftover</th>\n",
       "      <th>muni</th>\n",
       "      <th>region</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>('33238432', '447128', '444817', '95239113', '...</td>\n",
       "      <td>('10', '8', '6', '4', '3', '1')</td>\n",
       "      <td>33238432</td>\n",
       "      <td>NaN</td>\n",
       "      <td>447128.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>444817.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>95239113.0</td>\n",
       "      <td>95239112</td>\n",
       "      <td>NaN</td>\n",
       "      <td>442495</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>['4']</td>\n",
       "      <td>['3']</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>('81986147', '455404', '454228', '157924581', ...</td>\n",
       "      <td>('10', '8', '6', '3', '1')</td>\n",
       "      <td>81986147</td>\n",
       "      <td>NaN</td>\n",
       "      <td>455404.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>454228.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>157924581</td>\n",
       "      <td>NaN</td>\n",
       "      <td>442495</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>[]</td>\n",
       "      <td>['3']</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>('20160323', '441258', '442636', '95239183', '...</td>\n",
       "      <td>('10', '8', '5', '3', '1')</td>\n",
       "      <td>20160323</td>\n",
       "      <td>NaN</td>\n",
       "      <td>441258.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>442636.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>95239183</td>\n",
       "      <td>NaN</td>\n",
       "      <td>442495</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "      <td>[]</td>\n",
       "      <td>['3']</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>('17648737', '447454', '95239030', '442495')</td>\n",
       "      <td>('10', '6', '3', '1')</td>\n",
       "      <td>17648737</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>447454.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>95239030</td>\n",
       "      <td>NaN</td>\n",
       "      <td>442495</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>[]</td>\n",
       "      <td>['3']</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>('19761418', '450371', '449406', '95239146', '...</td>\n",
       "      <td>('10', '8', '6', '4', '3', '1')</td>\n",
       "      <td>19761418</td>\n",
       "      <td>NaN</td>\n",
       "      <td>450371.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>449406.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>95239146.0</td>\n",
       "      <td>95239143</td>\n",
       "      <td>NaN</td>\n",
       "      <td>442495</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>['4']</td>\n",
       "      <td>['3']</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                               chain  \\\n",
       "0  ('33238432', '447128', '444817', '95239113', '...   \n",
       "1  ('81986147', '455404', '454228', '157924581', ...   \n",
       "2  ('20160323', '441258', '442636', '95239183', '...   \n",
       "3       ('17648737', '447454', '95239030', '442495')   \n",
       "4  ('19761418', '450371', '449406', '95239146', '...   \n",
       "\n",
       "                          levchain        10   9         8   7         6  \\\n",
       "0  ('10', '8', '6', '4', '3', '1')  33238432 NaN  447128.0 NaN  444817.0   \n",
       "1       ('10', '8', '6', '3', '1')  81986147 NaN  455404.0 NaN  454228.0   \n",
       "2       ('10', '8', '5', '3', '1')  20160323 NaN  441258.0 NaN       NaN   \n",
       "3            ('10', '6', '3', '1')  17648737 NaN       NaN NaN  447454.0   \n",
       "4  ('10', '8', '6', '4', '3', '1')  19761418 NaN  450371.0 NaN  449406.0   \n",
       "\n",
       "          5           4          3   2       1  street  town leftover   muni  \\\n",
       "0       NaN  95239113.0   95239112 NaN  442495       8     6    ['4']  ['3']   \n",
       "1       NaN         NaN  157924581 NaN  442495       8     6       []  ['3']   \n",
       "2  442636.0         NaN   95239183 NaN  442495       8     5       []  ['3']   \n",
       "3       NaN         NaN   95239030 NaN  442495       6     1       []  ['3']   \n",
       "4       NaN  95239146.0   95239143 NaN  442495       8     6    ['4']  ['3']   \n",
       "\n",
       "                                    region  \n",
       "0  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "1  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "2  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "3  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "4  C:/Users/GlazkovOI/minzdrav/data/gar\\29  "
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfch = pd.read_csv(f'{region}_parsed_chains.csv', sep=';')\n",
    "dfch.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "metadata": {},
   "outputs": [],
   "source": [
    "import glob\n",
    "import random\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "from ast import literal_eval\n",
    "from tqdm import tqdm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 242280/242280 [00:03<00:00, 67104.15it/s]\n",
      "100%|██████████| 242280/242280 [00:03<00:00, 68789.28it/s]\n",
      "100%|██████████| 242280/242280 [00:01<00:00, 131230.92it/s]\n",
      "100%|██████████| 242280/242280 [00:02<00:00, 114007.61it/s]\n"
     ]
    }
   ],
   "source": [
    "for x in ['chain', 'levchain', 'leftover', 'muni']:\n",
    "    dfch[x] = [literal_eval(y) for y in tqdm(dfch[x])]\n",
    "for x in range(1, 11, 1):\n",
    "    dfch[f'{x}'] = dfch[f'{x}'].astype(str).apply(lambda y: y.split('.')[0] if y == y else y)\n",
    "    dfch[f'{x}'] = dfch[f'{x}'].apply(lambda y: y if y != '' else np.nan)\n",
    "for x in ['street', 'town', 'region']:\n",
    "    dfch[x] = dfch[x].astype(str).apply(lambda y: y.split('.')[0] if y == y else y)\n",
    "    dfch[x] = dfch[x].apply(lambda y: y if y != '' else np.nan)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>chain</th>\n",
       "      <th>levchain</th>\n",
       "      <th>10</th>\n",
       "      <th>9</th>\n",
       "      <th>8</th>\n",
       "      <th>7</th>\n",
       "      <th>6</th>\n",
       "      <th>5</th>\n",
       "      <th>4</th>\n",
       "      <th>3</th>\n",
       "      <th>2</th>\n",
       "      <th>1</th>\n",
       "      <th>street</th>\n",
       "      <th>town</th>\n",
       "      <th>leftover</th>\n",
       "      <th>muni</th>\n",
       "      <th>region</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>(33238432, 447128, 444817, 95239113, 95239112,...</td>\n",
       "      <td>(10, 8, 6, 4, 3, 1)</td>\n",
       "      <td>33238432</td>\n",
       "      <td>nan</td>\n",
       "      <td>447128</td>\n",
       "      <td>nan</td>\n",
       "      <td>444817</td>\n",
       "      <td>nan</td>\n",
       "      <td>95239113</td>\n",
       "      <td>95239112</td>\n",
       "      <td>nan</td>\n",
       "      <td>442495</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>[4]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>(81986147, 455404, 454228, 157924581, 442495)</td>\n",
       "      <td>(10, 8, 6, 3, 1)</td>\n",
       "      <td>81986147</td>\n",
       "      <td>nan</td>\n",
       "      <td>455404</td>\n",
       "      <td>nan</td>\n",
       "      <td>454228</td>\n",
       "      <td>nan</td>\n",
       "      <td>nan</td>\n",
       "      <td>157924581</td>\n",
       "      <td>nan</td>\n",
       "      <td>442495</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>(20160323, 441258, 442636, 95239183, 442495)</td>\n",
       "      <td>(10, 8, 5, 3, 1)</td>\n",
       "      <td>20160323</td>\n",
       "      <td>nan</td>\n",
       "      <td>441258</td>\n",
       "      <td>nan</td>\n",
       "      <td>nan</td>\n",
       "      <td>442636</td>\n",
       "      <td>nan</td>\n",
       "      <td>95239183</td>\n",
       "      <td>nan</td>\n",
       "      <td>442495</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>(17648737, 447454, 95239030, 442495)</td>\n",
       "      <td>(10, 6, 3, 1)</td>\n",
       "      <td>17648737</td>\n",
       "      <td>nan</td>\n",
       "      <td>nan</td>\n",
       "      <td>nan</td>\n",
       "      <td>447454</td>\n",
       "      <td>nan</td>\n",
       "      <td>nan</td>\n",
       "      <td>95239030</td>\n",
       "      <td>nan</td>\n",
       "      <td>442495</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>(19761418, 450371, 449406, 95239146, 95239143,...</td>\n",
       "      <td>(10, 8, 6, 4, 3, 1)</td>\n",
       "      <td>19761418</td>\n",
       "      <td>nan</td>\n",
       "      <td>450371</td>\n",
       "      <td>nan</td>\n",
       "      <td>449406</td>\n",
       "      <td>nan</td>\n",
       "      <td>95239146</td>\n",
       "      <td>95239143</td>\n",
       "      <td>nan</td>\n",
       "      <td>442495</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>[4]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                               chain             levchain  \\\n",
       "0  (33238432, 447128, 444817, 95239113, 95239112,...  (10, 8, 6, 4, 3, 1)   \n",
       "1      (81986147, 455404, 454228, 157924581, 442495)     (10, 8, 6, 3, 1)   \n",
       "2       (20160323, 441258, 442636, 95239183, 442495)     (10, 8, 5, 3, 1)   \n",
       "3               (17648737, 447454, 95239030, 442495)        (10, 6, 3, 1)   \n",
       "4  (19761418, 450371, 449406, 95239146, 95239143,...  (10, 8, 6, 4, 3, 1)   \n",
       "\n",
       "         10    9       8    7       6       5         4          3    2  \\\n",
       "0  33238432  nan  447128  nan  444817     nan  95239113   95239112  nan   \n",
       "1  81986147  nan  455404  nan  454228     nan       nan  157924581  nan   \n",
       "2  20160323  nan  441258  nan     nan  442636       nan   95239183  nan   \n",
       "3  17648737  nan     nan  nan  447454     nan       nan   95239030  nan   \n",
       "4  19761418  nan  450371  nan  449406     nan  95239146   95239143  nan   \n",
       "\n",
       "        1 street town leftover muni                                   region  \n",
       "0  442495      8    6      [4]  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "1  442495      8    6       []  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "2  442495      8    5       []  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "3  442495      6    1       []  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "4  442495      8    6      [4]  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  "
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfch.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('445407',\n",
       "  {'HOUSENUM': nan,\n",
       "   'HOUSENUM1': nan,\n",
       "   'HOUSENUM2': nan,\n",
       "   'HOUSETYPE': nan,\n",
       "   'HOUSETYPE1': nan,\n",
       "   'HOUSETYPE2': nan,\n",
       "   'ISACTIVE': 1,\n",
       "   'ISACTUAL': 1,\n",
       "   'LEVEL': '7',\n",
       "   'LEVELNAME': 'Элемент планировочной структуры',\n",
       "   'NAME': 'Лисьи Борки',\n",
       "   'NAME1': nan,\n",
       "   'NAME2': nan,\n",
       "   'OBJECTGUID': '425d519f-3636-41bd-ae7e-0c284911ada9',\n",
       "   'TYPELONGNAME': 'Территория садоводческого некоммерческого товарищества',\n",
       "   'TYPELONGNAME1': nan,\n",
       "   'TYPELONGNAME2': nan,\n",
       "   'TYPENAME': 'тер. СНТ',\n",
       "   'TYPENAME1': nan,\n",
       "   'TYPENAME2': nan}),\n",
       " ('95239078',\n",
       "  {'HOUSENUM': nan,\n",
       "   'HOUSENUM1': nan,\n",
       "   'HOUSENUM2': nan,\n",
       "   'HOUSETYPE': nan,\n",
       "   'HOUSETYPE1': nan,\n",
       "   'HOUSETYPE2': nan,\n",
       "   'ISACTIVE': 1,\n",
       "   'ISACTUAL': 1,\n",
       "   'LEVEL': '4',\n",
       "   'LEVELNAME': 'Сельское/городское поселение',\n",
       "   'NAME': 'Тарасовское',\n",
       "   'NAME1': nan,\n",
       "   'NAME2': nan,\n",
       "   'OBJECTGUID': '6621d717-388a-4533-9571-142c34a22acc',\n",
       "   'TYPELONGNAME': 'сельское поселение',\n",
       "   'TYPELONGNAME1': nan,\n",
       "   'TYPELONGNAME2': nan,\n",
       "   'TYPENAME': 'с.п.',\n",
       "   'TYPENAME1': nan,\n",
       "   'TYPENAME2': nan})]"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hadobjd = hadobj.set_index('OBJECTID').to_dict('index')\n",
    "[(k, v) for k, v in hadobjd.items()][:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0         (33238432, 447128, 444817, 95239113, 95239112,...\n",
       "1             (81986147, 455404, 454228, 157924581, 442495)\n",
       "2              (20160323, 441258, 442636, 95239183, 442495)\n",
       "3                      (17648737, 447454, 95239030, 442495)\n",
       "4         (19761418, 450371, 449406, 95239146, 95239143,...\n",
       "                                ...                        \n",
       "242275        (35960050, 448401, 449482, 157721129, 442495)\n",
       "242276               (104315614, 449097, 157721129, 442495)\n",
       "242277                (48020544, 452488, 162030634, 442495)\n",
       "242278          (2334368, 445757, 445753, 95239089, 442495)\n",
       "242279                (54186588, 447485, 157721129, 442495)\n",
       "Name: chain, Length: 242280, dtype: object"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfch.chain"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 242280/242280 [00:00<00:00, 537087.27it/s]\n"
     ]
    }
   ],
   "source": [
    "addr = {x[0]: [] for x in tqdm(dfch.chain)}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'33238432': [],\n",
       " '81986147': [],\n",
       " '20160323': [],\n",
       " '17648737': [],\n",
       " '19761418': [],\n",
       " '66374824': [],\n",
       " '8525133': [],\n",
       " '160526022': [],\n",
       " '101497947': [],\n",
       " '36435017': [],\n",
       " '51030179': [],\n",
       " '29556033': [],\n",
       " '5871102': [],\n",
       " '71890994': [],\n",
       " '3886163': [],\n",
       " '29576944': [],\n",
       " '84010846': [],\n",
       " '77143801': [],\n",
       " '82542086': [],\n",
       " '33283209': [],\n",
       " '103379321': [],\n",
       " '61069878': [],\n",
       " '2332775': [],\n",
       " '69729664': [],\n",
       " '20935047': [],\n",
       " '10642703': [],\n",
       " '24842958': [],\n",
       " '102283577': [],\n",
       " '33125466': [],\n",
       " '65688612': [],\n",
       " '72303006': [],\n",
       " '24018951': [],\n",
       " '71666941': [],\n",
       " '48694697': [],\n",
       " '33071340': [],\n",
       " '63888396': [],\n",
       " '74235167': [],\n",
       " '59634873': [],\n",
       " '60315464': [],\n",
       " '5204954': [],\n",
       " '161560840': [],\n",
       " '53512128': [],\n",
       " '9125679': [],\n",
       " '20167820': [],\n",
       " '74603217': [],\n",
       " '78326142': [],\n",
       " '1844371': [],\n",
       " '14401414': [],\n",
       " '47480061': [],\n",
       " '21545044': [],\n",
       " '79544336': [],\n",
       " '35609891': [],\n",
       " '1826570': [],\n",
       " '5872472': [],\n",
       " '3201353': [],\n",
       " '19746343': [],\n",
       " '54548187': [],\n",
       " '9356832': [],\n",
       " '32862791': [],\n",
       " '64156285': [],\n",
       " '48807322': [],\n",
       " '41782871': [],\n",
       " '60727075': [],\n",
       " '83856862': [],\n",
       " '75802867': [],\n",
       " '75154010': [],\n",
       " '33927616': [],\n",
       " '8715076': [],\n",
       " '48580908': [],\n",
       " '73733398': [],\n",
       " '3433024': [],\n",
       " '36213198': [],\n",
       " '83985930': [],\n",
       " '1906311': [],\n",
       " '100649276': [],\n",
       " '17583395': [],\n",
       " '75945714': [],\n",
       " '97211283': [],\n",
       " '67475976': [],\n",
       " '3698817': [],\n",
       " '8895704': [],\n",
       " '43061053': [],\n",
       " '53660462': [],\n",
       " '20436717': [],\n",
       " '14979340': [],\n",
       " '5652336': [],\n",
       " '78518657': [],\n",
       " '29233770': [],\n",
       " '60835890': [],\n",
       " '3296319': [],\n",
       " '71195251': [],\n",
       " '29028542': [],\n",
       " '74544311': [],\n",
       " '5345610': [],\n",
       " '60362979': [],\n",
       " '15517442': [],\n",
       " '159314197': [],\n",
       " '51486066': [],\n",
       " '46650933': [],\n",
       " '47896029': [],\n",
       " '66996181': [],\n",
       " '26047047': [],\n",
       " '81894969': [],\n",
       " '50993949': [],\n",
       " '38499637': [],\n",
       " '11043218': [],\n",
       " '30819736': [],\n",
       " '62346387': [],\n",
       " '30721613': [],\n",
       " '45432196': [],\n",
       " '7172710': [],\n",
       " '64407084': [],\n",
       " '27078891': [],\n",
       " '1824927': [],\n",
       " '59918459': [],\n",
       " '70818802': [],\n",
       " '67623567': [],\n",
       " '32718003': [],\n",
       " '42375253': [],\n",
       " '2227609': [],\n",
       " '98292270': [],\n",
       " '6137424': [],\n",
       " '61458262': [],\n",
       " '161592371': [],\n",
       " '29141178': [],\n",
       " '77306487': [],\n",
       " '13363027': [],\n",
       " '57300356': [],\n",
       " '28724509': [],\n",
       " '61143631': [],\n",
       " '45593632': [],\n",
       " '82349236': [],\n",
       " '60918617': [],\n",
       " '83372192': [],\n",
       " '26370329': [],\n",
       " '18766105': [],\n",
       " '13142463': [],\n",
       " '3110675': [],\n",
       " '101339785': [],\n",
       " '160691111': [],\n",
       " '14059354': [],\n",
       " '99705683': [],\n",
       " '14285963': [],\n",
       " '73996633': [],\n",
       " '20053044': [],\n",
       " '63430249': [],\n",
       " '73407096': [],\n",
       " '66205138': [],\n",
       " '34147733': [],\n",
       " '41456301': [],\n",
       " '158977465': [],\n",
       " '54249701': [],\n",
       " '14189997': [],\n",
       " '34819995': [],\n",
       " '65626204': [],\n",
       " '26046182': [],\n",
       " '30072157': [],\n",
       " '19417277': [],\n",
       " '76899378': [],\n",
       " '12148166': [],\n",
       " '65204881': [],\n",
       " '49217218': [],\n",
       " '58457931': [],\n",
       " '58928945': [],\n",
       " '61628325': [],\n",
       " '36687319': [],\n",
       " '67803367': [],\n",
       " '79657858': [],\n",
       " '58856817': [],\n",
       " '61111248': [],\n",
       " '157301695': [],\n",
       " '161977612': [],\n",
       " '54694258': [],\n",
       " '42327114': [],\n",
       " '44592682': [],\n",
       " '67320670': [],\n",
       " '99672094': [],\n",
       " '23115120': [],\n",
       " '19357126': [],\n",
       " '100289380': [],\n",
       " '66347416': [],\n",
       " '72677745': [],\n",
       " '96298532': [],\n",
       " '78795828': [],\n",
       " '76347271': [],\n",
       " '50156720': [],\n",
       " '162395282': [],\n",
       " '161382715': [],\n",
       " '12019153': [],\n",
       " '23625474': [],\n",
       " '104913458': [],\n",
       " '24328818': [],\n",
       " '47866039': [],\n",
       " '58337751': [],\n",
       " '39291874': [],\n",
       " '59865429': [],\n",
       " '159455440': [],\n",
       " '65617108': [],\n",
       " '54635334': [],\n",
       " '65849589': [],\n",
       " '6698056': [],\n",
       " '63665391': [],\n",
       " '73589891': [],\n",
       " '160386198': [],\n",
       " '63952404': [],\n",
       " '40408326': [],\n",
       " '160526038': [],\n",
       " '34738458': [],\n",
       " '16968045': [],\n",
       " '48224870': [],\n",
       " '30425840': [],\n",
       " '159757199': [],\n",
       " '77067898': [],\n",
       " '160490982': [],\n",
       " '63759789': [],\n",
       " '13615129': [],\n",
       " '12908849': [],\n",
       " '38787851': [],\n",
       " '9876473': [],\n",
       " '161668148': [],\n",
       " '16521827': [],\n",
       " '64383861': [],\n",
       " '6282243': [],\n",
       " '16833946': [],\n",
       " '75405882': [],\n",
       " '30986897': [],\n",
       " '161769498': [],\n",
       " '6052082': [],\n",
       " '23473526': [],\n",
       " '105112596': [],\n",
       " '46197527': [],\n",
       " '20623338': [],\n",
       " '62829375': [],\n",
       " '43061879': [],\n",
       " '66586321': [],\n",
       " '58357881': [],\n",
       " '22688724': [],\n",
       " '82746876': [],\n",
       " '52159258': [],\n",
       " '23451792': [],\n",
       " '55931375': [],\n",
       " '19623525': [],\n",
       " '39164951': [],\n",
       " '29244390': [],\n",
       " '36816885': [],\n",
       " '159157682': [],\n",
       " '38304734': [],\n",
       " '81094716': [],\n",
       " '9392199': [],\n",
       " '72171982': [],\n",
       " '76105167': [],\n",
       " '16236328': [],\n",
       " '83157833': [],\n",
       " '69696386': [],\n",
       " '78238068': [],\n",
       " '75741594': [],\n",
       " '81865189': [],\n",
       " '77622708': [],\n",
       " '53926401': [],\n",
       " '62733004': [],\n",
       " '25346043': [],\n",
       " '16742236': [],\n",
       " '19398853': [],\n",
       " '46274047': [],\n",
       " '84304396': [],\n",
       " '61057319': [],\n",
       " '161580794': [],\n",
       " '1483777': [],\n",
       " '16529339': [],\n",
       " '10833883': [],\n",
       " '7334982': [],\n",
       " '59644847': [],\n",
       " '75624413': [],\n",
       " '81010931': [],\n",
       " '161873035': [],\n",
       " '76349232': [],\n",
       " '66592045': [],\n",
       " '100595833': [],\n",
       " '37577401': [],\n",
       " '10667773': [],\n",
       " '81452797': [],\n",
       " '12438009': [],\n",
       " '25172841': [],\n",
       " '3166120': [],\n",
       " '32944442': [],\n",
       " '83621576': [],\n",
       " '30761867': [],\n",
       " '36490122': [],\n",
       " '28752631': [],\n",
       " '160929073': [],\n",
       " '13800363': [],\n",
       " '77647887': [],\n",
       " '44591295': [],\n",
       " '101851577': [],\n",
       " '82275410': [],\n",
       " '31990450': [],\n",
       " '38876669': [],\n",
       " '73380982': [],\n",
       " '56550912': [],\n",
       " '70362771': [],\n",
       " '64693983': [],\n",
       " '17243210': [],\n",
       " '54024959': [],\n",
       " '78502346': [],\n",
       " '52700499': [],\n",
       " '47937454': [],\n",
       " '16461501': [],\n",
       " '11258612': [],\n",
       " '68622301': [],\n",
       " '45524961': [],\n",
       " '38302298': [],\n",
       " '27686908': [],\n",
       " '60732683': [],\n",
       " '25452959': [],\n",
       " '22677626': [],\n",
       " '55730189': [],\n",
       " '102001377': [],\n",
       " '6938157': [],\n",
       " '66498464': [],\n",
       " '158730193': [],\n",
       " '159106667': [],\n",
       " '27674190': [],\n",
       " '18878287': [],\n",
       " '47451558': [],\n",
       " '24115772': [],\n",
       " '16596887': [],\n",
       " '15798994': [],\n",
       " '3417553': [],\n",
       " '29221540': [],\n",
       " '59589078': [],\n",
       " '25695616': [],\n",
       " '61574500': [],\n",
       " '161383156': [],\n",
       " '32882313': [],\n",
       " '10055154': [],\n",
       " '76541312': [],\n",
       " '66478543': [],\n",
       " '30159982': [],\n",
       " '68880110': [],\n",
       " '10201931': [],\n",
       " '67102052': [],\n",
       " '72970501': [],\n",
       " '33315176': [],\n",
       " '79182622': [],\n",
       " '22178760': [],\n",
       " '161967814': [],\n",
       " '52156389': [],\n",
       " '159312855': [],\n",
       " '12192410': [],\n",
       " '81777472': [],\n",
       " '31187973': [],\n",
       " '6465587': [],\n",
       " '20016437': [],\n",
       " '25532719': [],\n",
       " '24751856': [],\n",
       " '38149517': [],\n",
       " '58025722': [],\n",
       " '17877122': [],\n",
       " '44693730': [],\n",
       " '78772125': [],\n",
       " '43869856': [],\n",
       " '72235682': [],\n",
       " '26329659': [],\n",
       " '36222286': [],\n",
       " '159264214': [],\n",
       " '46540597': [],\n",
       " '45124180': [],\n",
       " '76214997': [],\n",
       " '41728497': [],\n",
       " '64731413': [],\n",
       " '25679274': [],\n",
       " '36858060': [],\n",
       " '104212012': [],\n",
       " '45804628': [],\n",
       " '48620010': [],\n",
       " '161348273': [],\n",
       " '162122047': [],\n",
       " '19852258': [],\n",
       " '77022280': [],\n",
       " '11234266': [],\n",
       " '39143520': [],\n",
       " '4257705': [],\n",
       " '22167335': [],\n",
       " '22774198': [],\n",
       " '50072686': [],\n",
       " '82168065': [],\n",
       " '27079659': [],\n",
       " '66647122': [],\n",
       " '18342459': [],\n",
       " '8192012': [],\n",
       " '70491253': [],\n",
       " '69303102': [],\n",
       " '60845379': [],\n",
       " '46528720': [],\n",
       " '50496093': [],\n",
       " '3400744': [],\n",
       " '103838518': [],\n",
       " '42688735': [],\n",
       " '25260086': [],\n",
       " '53323498': [],\n",
       " '41282884': [],\n",
       " '19948604': [],\n",
       " '47240580': [],\n",
       " '71623968': [],\n",
       " '57003810': [],\n",
       " '18230031': [],\n",
       " '84329381': [],\n",
       " '7043335': [],\n",
       " '42469955': [],\n",
       " '28831171': [],\n",
       " '9366164': [],\n",
       " '38369642': [],\n",
       " '83806098': [],\n",
       " '33127757': [],\n",
       " '30270547': [],\n",
       " '79015046': [],\n",
       " '1713440': [],\n",
       " '23033908': [],\n",
       " '39134268': [],\n",
       " '41918282': [],\n",
       " '14830078': [],\n",
       " '14034784': [],\n",
       " '50762972': [],\n",
       " '80877854': [],\n",
       " '61562192': [],\n",
       " '26546738': [],\n",
       " '102001283': [],\n",
       " '68713047': [],\n",
       " '38477424': [],\n",
       " '9279985': [],\n",
       " '77097910': [],\n",
       " '60471963': [],\n",
       " '52240706': [],\n",
       " '75946283': [],\n",
       " '47023671': [],\n",
       " '77323761': [],\n",
       " '11672043': [],\n",
       " '37826133': [],\n",
       " '1480940': [],\n",
       " '82240318': [],\n",
       " '4666883': [],\n",
       " '78305168': [],\n",
       " '100787582': [],\n",
       " '99672331': [],\n",
       " '83627824': [],\n",
       " '13256886': [],\n",
       " '63601589': [],\n",
       " '159074421': [],\n",
       " '37823648': [],\n",
       " '79819338': [],\n",
       " '21220737': [],\n",
       " '105226952': [],\n",
       " '16201154': [],\n",
       " '76383113': [],\n",
       " '53861742': [],\n",
       " '69169243': [],\n",
       " '39434619': [],\n",
       " '6925573': [],\n",
       " '65079012': [],\n",
       " '65709423': [],\n",
       " '61501795': [],\n",
       " '15655926': [],\n",
       " '33854006': [],\n",
       " '63753821': [],\n",
       " '62084138': [],\n",
       " '15021834': [],\n",
       " '59305920': [],\n",
       " '41288957': [],\n",
       " '21730499': [],\n",
       " '102283578': [],\n",
       " '46992671': [],\n",
       " '158957757': [],\n",
       " '36579576': [],\n",
       " '9348146': [],\n",
       " '47824597': [],\n",
       " '71762171': [],\n",
       " '19454180': [],\n",
       " '14449887': [],\n",
       " '18020171': [],\n",
       " '9940067': [],\n",
       " '66333898': [],\n",
       " '32977886': [],\n",
       " '64471867': [],\n",
       " '29790206': [],\n",
       " '159732167': [],\n",
       " '72058151': [],\n",
       " '55478442': [],\n",
       " '12509469': [],\n",
       " '15516141': [],\n",
       " '18126478': [],\n",
       " '73369567': [],\n",
       " '50992520': [],\n",
       " '44993059': [],\n",
       " '32878388': [],\n",
       " '70927331': [],\n",
       " '20840478': [],\n",
       " '99706510': [],\n",
       " '69243701': [],\n",
       " '50135472': [],\n",
       " '49111421': [],\n",
       " '75228259': [],\n",
       " '81403937': [],\n",
       " '101498090': [],\n",
       " '73495661': [],\n",
       " '70123865': [],\n",
       " '65575369': [],\n",
       " '47820175': [],\n",
       " '13558276': [],\n",
       " '44449904': [],\n",
       " '48565778': [],\n",
       " '15933004': [],\n",
       " '58743311': [],\n",
       " '74068324': [],\n",
       " '61236624': [],\n",
       " '73209214': [],\n",
       " '71140669': [],\n",
       " '42786746': [],\n",
       " '43308954': [],\n",
       " '45653551': [],\n",
       " '26027172': [],\n",
       " '54089718': [],\n",
       " '54802175': [],\n",
       " '12861874': [],\n",
       " '159415069': [],\n",
       " '9357039': [],\n",
       " '157486388': [],\n",
       " '76017491': [],\n",
       " '4525474': [],\n",
       " '83304525': [],\n",
       " '42811338': [],\n",
       " '102470031': [],\n",
       " '69225186': [],\n",
       " '78918396': [],\n",
       " '68222541': [],\n",
       " '58661955': [],\n",
       " '6196006': [],\n",
       " '12948292': [],\n",
       " '73192700': [],\n",
       " '44390002': [],\n",
       " '1916007': [],\n",
       " '4951390': [],\n",
       " '57299096': [],\n",
       " '54091374': [],\n",
       " '12956349': [],\n",
       " '35709959': [],\n",
       " '14601132': [],\n",
       " '76166275': [],\n",
       " '49696493': [],\n",
       " '41825235': [],\n",
       " '44334351': [],\n",
       " '82284759': [],\n",
       " '66077245': [],\n",
       " '49526212': [],\n",
       " '8823784': [],\n",
       " '72133576': [],\n",
       " '7666025': [],\n",
       " '6561614': [],\n",
       " '62553828': [],\n",
       " '48299162': [],\n",
       " '11288364': [],\n",
       " '16684709': [],\n",
       " '104414561': [],\n",
       " '161474206': [],\n",
       " '35605984': [],\n",
       " '33765560': [],\n",
       " '65318916': [],\n",
       " '45865768': [],\n",
       " '97884705': [],\n",
       " '66558651': [],\n",
       " '17941635': [],\n",
       " '29017482': [],\n",
       " '32825895': [],\n",
       " '96761309': [],\n",
       " '5977261': [],\n",
       " '2785413': [],\n",
       " '12152116': [],\n",
       " '14061657': [],\n",
       " '59039127': [],\n",
       " '60963156': [],\n",
       " '33862059': [],\n",
       " '69579517': [],\n",
       " '48216519': [],\n",
       " '31726015': [],\n",
       " '62048264': [],\n",
       " '34998409': [],\n",
       " '17226682': [],\n",
       " '47697314': [],\n",
       " '161460949': [],\n",
       " '17851314': [],\n",
       " '44451884': [],\n",
       " '162549061': [],\n",
       " '7647703': [],\n",
       " '14003846': [],\n",
       " '58127820': [],\n",
       " '158890171': [],\n",
       " '28718711': [],\n",
       " '157600681': [],\n",
       " '56382563': [],\n",
       " '67113105': [],\n",
       " '159767975': [],\n",
       " '28536954': [],\n",
       " '62686386': [],\n",
       " '36280494': [],\n",
       " '33415633': [],\n",
       " '29912904': [],\n",
       " '51033399': [],\n",
       " '44260909': [],\n",
       " '43991792': [],\n",
       " '79956590': [],\n",
       " '49160678': [],\n",
       " '73737512': [],\n",
       " '6789331': [],\n",
       " '17436245': [],\n",
       " '58091108': [],\n",
       " '53509833': [],\n",
       " '64258906': [],\n",
       " '16570416': [],\n",
       " '48909160': [],\n",
       " '8172748': [],\n",
       " '44825162': [],\n",
       " '47657128': [],\n",
       " '1938123': [],\n",
       " '52114683': [],\n",
       " '83355138': [],\n",
       " '69762155': [],\n",
       " '49981616': [],\n",
       " '41318460': [],\n",
       " '60816277': [],\n",
       " '37108020': [],\n",
       " '21235375': [],\n",
       " '37400210': [],\n",
       " '30009564': [],\n",
       " '44734945': [],\n",
       " '76204763': [],\n",
       " '46355387': [],\n",
       " '96135152': [],\n",
       " '17344844': [],\n",
       " '42756395': [],\n",
       " '11751518': [],\n",
       " '18103838': [],\n",
       " '38399932': [],\n",
       " '28944097': [],\n",
       " '57900435': [],\n",
       " '17461029': [],\n",
       " '29324398': [],\n",
       " '20559328': [],\n",
       " '27535029': [],\n",
       " '29780780': [],\n",
       " '98459758': [],\n",
       " '51700606': [],\n",
       " '162359759': [],\n",
       " '52772943': [],\n",
       " '47164105': [],\n",
       " '30349237': [],\n",
       " '9229426': [],\n",
       " '42470406': [],\n",
       " '25425414': [],\n",
       " '61042282': [],\n",
       " '25445130': [],\n",
       " '18997290': [],\n",
       " '70718891': [],\n",
       " '66631054': [],\n",
       " '46899197': [],\n",
       " '14346465': [],\n",
       " '104370260': [],\n",
       " '43412066': [],\n",
       " '49674238': [],\n",
       " '83463512': [],\n",
       " '1699185': [],\n",
       " '20328975': [],\n",
       " '45065635': [],\n",
       " '83796518': [],\n",
       " '3105227': [],\n",
       " '29729482': [],\n",
       " '32255349': [],\n",
       " '55680415': [],\n",
       " '18304941': [],\n",
       " '68163970': [],\n",
       " '72381033': [],\n",
       " '35722468': [],\n",
       " '49680352': [],\n",
       " '19799902': [],\n",
       " '48374763': [],\n",
       " '73308961': [],\n",
       " '31425300': [],\n",
       " '68870805': [],\n",
       " '46369795': [],\n",
       " '81132268': [],\n",
       " '55618913': [],\n",
       " '159330531': [],\n",
       " '26496647': [],\n",
       " '59676459': [],\n",
       " '49165942': [],\n",
       " '101389841': [],\n",
       " '70892441': [],\n",
       " '83684705': [],\n",
       " '18355902': [],\n",
       " '2671191': [],\n",
       " '53836542': [],\n",
       " '68295747': [],\n",
       " '78929159': [],\n",
       " '52358290': [],\n",
       " '74650955': [],\n",
       " '65726816': [],\n",
       " '1879439': [],\n",
       " '8104393': [],\n",
       " '76275026': [],\n",
       " '19494734': [],\n",
       " '41377534': [],\n",
       " '61065220': [],\n",
       " '22993709': [],\n",
       " '31418467': [],\n",
       " '47827358': [],\n",
       " '12049573': [],\n",
       " '22474553': [],\n",
       " '52180420': [],\n",
       " '23052932': [],\n",
       " '13358817': [],\n",
       " '14650211': [],\n",
       " '80461710': [],\n",
       " '57725975': [],\n",
       " '52275919': [],\n",
       " '80211744': [],\n",
       " '73049979': [],\n",
       " '64211977': [],\n",
       " '25285024': [],\n",
       " '77197699': [],\n",
       " '60859226': [],\n",
       " '63040572': [],\n",
       " '64400196': [],\n",
       " '70527058': [],\n",
       " '59012454': [],\n",
       " '30876989': [],\n",
       " '23283313': [],\n",
       " '5699412': [],\n",
       " '22247566': [],\n",
       " '75905061': [],\n",
       " '6346769': [],\n",
       " '24648931': [],\n",
       " '27560444': [],\n",
       " '79817426': [],\n",
       " '79841338': [],\n",
       " '25352817': [],\n",
       " '81933852': [],\n",
       " '20798168': [],\n",
       " '102555909': [],\n",
       " '30885897': [],\n",
       " '18875892': [],\n",
       " '67849540': [],\n",
       " '2306602': [],\n",
       " '79673266': [],\n",
       " '13800797': [],\n",
       " '48749927': [],\n",
       " '10902982': [],\n",
       " '69250782': [],\n",
       " '27020770': [],\n",
       " '17485531': [],\n",
       " '8621771': [],\n",
       " '19547393': [],\n",
       " '26424892': [],\n",
       " '10865077': [],\n",
       " '53014216': [],\n",
       " '44545597': [],\n",
       " '44832737': [],\n",
       " '82855167': [],\n",
       " '13663475': [],\n",
       " '22983516': [],\n",
       " '58561094': [],\n",
       " '162357215': [],\n",
       " '35027276': [],\n",
       " '15412823': [],\n",
       " '32692290': [],\n",
       " '81750388': [],\n",
       " '71596487': [],\n",
       " '78841308': [],\n",
       " '81433184': [],\n",
       " '30141871': [],\n",
       " '160687673': [],\n",
       " '32605369': [],\n",
       " '36418986': [],\n",
       " '42122774': [],\n",
       " '21718287': [],\n",
       " '55969302': [],\n",
       " '5683511': [],\n",
       " '160355593': [],\n",
       " '16996272': [],\n",
       " '9363245': [],\n",
       " '65480155': [],\n",
       " '20532532': [],\n",
       " '48198781': [],\n",
       " '37699353': [],\n",
       " '101229758': [],\n",
       " '5717123': [],\n",
       " '3399795': [],\n",
       " '38500169': [],\n",
       " '64473589': [],\n",
       " '24409855': [],\n",
       " '101972291': [],\n",
       " '2884564': [],\n",
       " '63855492': [],\n",
       " '63715722': [],\n",
       " '78491936': [],\n",
       " '63877970': [],\n",
       " '76179827': [],\n",
       " '77818085': [],\n",
       " '50681342': [],\n",
       " '76242332': [],\n",
       " '158694405': [],\n",
       " '68095598': [],\n",
       " '82640291': [],\n",
       " '161428140': [],\n",
       " '40838729': [],\n",
       " '101790799': [],\n",
       " '5770286': [],\n",
       " '32620528': [],\n",
       " '81942373': [],\n",
       " '161792725': [],\n",
       " '48385939': [],\n",
       " '5237063': [],\n",
       " '77375055': [],\n",
       " '81387614': [],\n",
       " '61402290': [],\n",
       " '45724678': [],\n",
       " '103275173': [],\n",
       " '21696779': [],\n",
       " '82932267': [],\n",
       " '44885666': [],\n",
       " '79339315': [],\n",
       " '45371960': [],\n",
       " '66598470': [],\n",
       " '161582262': [],\n",
       " '61681920': [],\n",
       " '160533192': [],\n",
       " '161982067': [],\n",
       " '102803922': [],\n",
       " '3111469': [],\n",
       " '62061502': [],\n",
       " '44543862': [],\n",
       " '13845690': [],\n",
       " '68336221': [],\n",
       " '77198526': [],\n",
       " '30013927': [],\n",
       " '28192079': [],\n",
       " '8728047': [],\n",
       " '3877329': [],\n",
       " '26316639': [],\n",
       " '30448734': [],\n",
       " '68689559': [],\n",
       " '50574951': [],\n",
       " '70142416': [],\n",
       " '19919450': [],\n",
       " '24321479': [],\n",
       " '19309559': [],\n",
       " '31336795': [],\n",
       " '15051554': [],\n",
       " '16342746': [],\n",
       " '83541982': [],\n",
       " '26079391': [],\n",
       " '23003022': [],\n",
       " '52979253': [],\n",
       " '46916360': [],\n",
       " '55337654': [],\n",
       " '27930539': [],\n",
       " '6974507': [],\n",
       " '158337196': [],\n",
       " '49688694': [],\n",
       " '49332160': [],\n",
       " '71136086': [],\n",
       " '7896979': [],\n",
       " '62580509': [],\n",
       " '100244166': [],\n",
       " '39678553': [],\n",
       " '78150045': [],\n",
       " '66182635': [],\n",
       " '157386854': [],\n",
       " '65573688': [],\n",
       " '14081900': [],\n",
       " '49993434': [],\n",
       " '31893390': [],\n",
       " '22303280': [],\n",
       " '159180246': [],\n",
       " '30760344': [],\n",
       " '6197767': [],\n",
       " '83448144': [],\n",
       " '77038789': [],\n",
       " '19784090': [],\n",
       " '80808310': [],\n",
       " '58788051': [],\n",
       " '2700815': [],\n",
       " '56620288': [],\n",
       " '31558904': [],\n",
       " '76224247': [],\n",
       " '39275492': [],\n",
       " '13006909': [],\n",
       " '35089643': [],\n",
       " '69966513': [],\n",
       " '80529433': [],\n",
       " '46957584': [],\n",
       " '61465502': [],\n",
       " '21315691': [],\n",
       " '41272927': [],\n",
       " '40101937': [],\n",
       " '54747630': [],\n",
       " '27904386': [],\n",
       " '30068794': [],\n",
       " '78364210': [],\n",
       " '23250021': [],\n",
       " '30886229': [],\n",
       " '50322287': [],\n",
       " '10044880': [],\n",
       " '62040299': [],\n",
       " '28416139': [],\n",
       " '35090604': [],\n",
       " '32344098': [],\n",
       " '79920208': [],\n",
       " '22692589': [],\n",
       " '101115494': [],\n",
       " '56250078': [],\n",
       " '58406769': [],\n",
       " '32046592': [],\n",
       " '78110640': [],\n",
       " '7144468': [],\n",
       " '103838617': [],\n",
       " '20197827': [],\n",
       " '83642100': [],\n",
       " '79784262': [],\n",
       " '30747165': [],\n",
       " '5318557': [],\n",
       " '19951984': [],\n",
       " '66747134': [],\n",
       " '3721635': [],\n",
       " '23303880': [],\n",
       " '103848041': [],\n",
       " '47895772': [],\n",
       " '83761610': [],\n",
       " '67343429': [],\n",
       " '14399002': [],\n",
       " '29105995': [],\n",
       " '70229418': [],\n",
       " '97419172': [],\n",
       " '16348375': [],\n",
       " '34790845': [],\n",
       " '12329823': [],\n",
       " '60425992': [],\n",
       " '67850547': [],\n",
       " '27312814': [],\n",
       " '17384312': [],\n",
       " '29493891': [],\n",
       " '49233773': [],\n",
       " '73922176': [],\n",
       " '15080346': [],\n",
       " '35455221': [],\n",
       " '67020255': [],\n",
       " '55755795': [],\n",
       " '45691300': [],\n",
       " '6074929': [],\n",
       " '159180194': [],\n",
       " '42684545': [],\n",
       " '160330345': [],\n",
       " '24786054': [],\n",
       " '67277922': [],\n",
       " '56664208': [],\n",
       " '22127698': [],\n",
       " '30779084': [],\n",
       " '103862062': [],\n",
       " '28556939': [],\n",
       " '24798159': [],\n",
       " '57908431': [],\n",
       " '34728277': [],\n",
       " '3204068': [],\n",
       " '37950985': [],\n",
       " '61555351': [],\n",
       " '53448552': [],\n",
       " '63489083': [],\n",
       " '28651299': [],\n",
       " '73796862': [],\n",
       " '61487809': [],\n",
       " '52975203': [],\n",
       " '48825714': [],\n",
       " '21571736': [],\n",
       " '65150692': [],\n",
       " '102568511': [],\n",
       " '63579525': [],\n",
       " '71725640': [],\n",
       " '62520594': [],\n",
       " '14124168': [],\n",
       " '51126221': [],\n",
       " '81765928': [],\n",
       " '60929316': [],\n",
       " '50991944': [],\n",
       " '79338862': [],\n",
       " '52383755': [],\n",
       " '9118045': [],\n",
       " '161582277': [],\n",
       " '31176367': [],\n",
       " '55564203': [],\n",
       " '32942051': [],\n",
       " '76209845': [],\n",
       " '29373350': [],\n",
       " '161582222': [],\n",
       " ...}"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "addr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "  0%|          | 0/242280 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 242280/242280 [00:00<00:00, 479956.69it/s] \n",
      "100%|██████████| 242280/242280 [00:02<00:00, 113755.37it/s]\n",
      "C:\\Users\\GlazkovOI\\AppData\\Local\\Temp\\ipykernel_7896\\1617512610.py:29: DeprecationWarning: Sampling from a set deprecated\n",
      "since Python 3.9 and will be removed in a subsequent version.\n",
      "  sample = random.sample(addresses.keys(), 10)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'75854698': 'дом d2499f90-9088-4597-8b8a-2c8ed9ede408 24 деревня ecffbc9d-f8e6-4762-9277-e51ef6b876f1 бритвино муниципальный округ da8c94c5-bcf7-4c3f-ae58-7b90abd40249 устьянский область 294277aa-e25d-428c-95ad-46719c4ddb44 архангельская',\n",
       " '20224480': 'дом a4a968b2-da86-4921-bcbc-3b849c5bbbed 10 улица 969243ec-3704-434a-b012-3a8a7616d228 лесная село 5217cf83-fa42-48d2-8b69-95e93fed17b9 ровдино муниципальный округ c3a30f78-f9c3-4e76-9a4a-d9e4c70dfc86 шенкурский область 294277aa-e25d-428c-95ad-46719c4ddb44 архангельская',\n",
       " '45676528': 'дом 098aac01-7e04-4667-a1e5-25fef73cce1e 42 улица cd30ea9f-2b48-46de-9464-87d94d52b58b свободы город 53e6ddd5-a1fb-4444-89a4-3952ef6f114b онега городское поселение 004293aa-ece2-4872-92e9-80aae9e3b97a онежское муниципальный район 6dc677f9-ab8a-4194-a31f-a514d1378dc8 онежский область 294277aa-e25d-428c-95ad-46719c4ddb44 архангельская',\n",
       " '20465079': 'дом 8d1de0ef-6eca-4c52-855e-e2c45e1b6593 26 улица 54dd0111-62c2-4090-9ff6-3b43af3e54fa центральная деревня 71a1c2d1-ce82-431b-8c5b-51e9af9927d5 полинская муниципальный округ 487dab72-2f5f-41c5-9d24-50d00cfbcf8b няндомский область 294277aa-e25d-428c-95ad-46719c4ddb44 архангельская',\n",
       " '43157449': 'дом 8e3a927d-f971-409b-91e9-c85ce167613a 22 улица e8de5c51-b064-44b9-9347-803b64670396 лесная поселок fc3e6b03-3630-48e1-ac34-21d910ffa7ea авнюгский муниципальный округ a0648c35-501c-433b-a858-412d9147532a верхнетоемский область 294277aa-e25d-428c-95ad-46719c4ddb44 архангельская',\n",
       " '21221673': 'дом fcdaa125-5ab2-4f52-8d80-38283057e2e5 32 деревня e56296fd-97f7-40a5-a76b-3dbb1c2fef1b залахотье муниципальный округ 830ff2f5-1811-442f-90e8-7d009f253967 приморский область 294277aa-e25d-428c-95ad-46719c4ddb44 архангельская',\n",
       " '97526674': 'дом 0167c001-e3da-4e5c-baf1-026a344b34ed 4 переулок d9d23627-aea3-402a-99aa-4c8c762fffb7 1-й удачный деревня 10a2ea1a-1d96-470b-895c-52d6d0c15b9c верхнее ладино муниципальный округ 830ff2f5-1811-442f-90e8-7d009f253967 приморский область 294277aa-e25d-428c-95ad-46719c4ddb44 архангельская',\n",
       " '62762136': 'дом 0419c533-3a20-425a-b577-9dd5c737ae4c 12а строение 1 проезд 9b83cd1d-6d0a-4c7d-8029-bccce1d28514 тепличный город 32747c72-c08b-4440-b340-91f48d72f9db северодвинск городской округ 413ad5f9-fb3d-431e-8619-0376df3e9f4b северодвинск область 294277aa-e25d-428c-95ad-46719c4ddb44 архангельская',\n",
       " '48649951': 'дом db5e1036-2e6a-4c9d-8c0b-234b32f2bbae 13 улица 0bed7173-589d-4eba-b276-911ac7b836ee советская деревня 948faed8-ecce-48c0-a777-b9cc13e54b89 лопшеньга муниципальный округ 830ff2f5-1811-442f-90e8-7d009f253967 приморский область 294277aa-e25d-428c-95ad-46719c4ddb44 архангельская',\n",
       " '2877671': 'здание afb50f46-f94b-4e90-a40f-5cee449ba8b4 17 корпус 23 улица 28e0996e-c70b-4fb7-b420-18198f6a4ff4 неделина город 977c7606-1b37-4424-84f7-b0c66c3e4b94 мирный городской округ 89a3b2a5-15e0-4b5b-802e-9fdf0b7386ac мирный область 294277aa-e25d-428c-95ad-46719c4ddb44 архангельская'}"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "addresses = {x[0]: [] for x in tqdm(dfch.chain)}\n",
    "for x in tqdm(dfch.chain):\n",
    "    for y in x:\n",
    "        if y != '0':\n",
    "            guid = hadobjd[y]['OBJECTGUID']\n",
    "            tpln = hadobjd[y]['TYPELONGNAME']\n",
    "            tpln1 = hadobjd[y]['TYPELONGNAME1']\n",
    "            tpln2 = hadobjd[y]['TYPELONGNAME2']\n",
    "            if tpln == tpln:\n",
    "                addresses[x[0]].append(tpln)\n",
    "            if guid == guid:\n",
    "                addresses[x[0]].append(guid)\n",
    "            if hadobjd[y]['LEVEL'] != '10':\n",
    "                addresses[x[0]].append(hadobjd[y]['NAME'])\n",
    "            else:\n",
    "                addresses[x[0]].append(hadobjd[y]['HOUSENUM'])\n",
    "                if hadobjd[y]['HOUSENUM1'] == hadobjd[y]['HOUSENUM1']:\n",
    "                    if tpln1 == tpln1:\n",
    "                        addresses[x[0]].append(tpln1)\n",
    "                    addresses[x[0]].append(hadobjd[y]['HOUSENUM1'])\n",
    "                    if hadobjd[y]['HOUSENUM2'] == hadobjd[y]['HOUSENUM2']:\n",
    "                        if tpln2 == tpln2:\n",
    "                            addresses[x[0]].append(tpln2)\n",
    "                        addresses[x[0]].append(hadobjd[y]['HOUSENUM2'])\n",
    "addresses = {\n",
    "    k: ' '.join(v)\n",
    "    for k, v in addresses.items()\n",
    "}\n",
    "sample = random.sample(addresses.keys(), 10)\n",
    "{s: addresses[s].lower() for s in sample}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['75854698',\n",
       " '20224480',\n",
       " '45676528',\n",
       " '20465079',\n",
       " '43157449',\n",
       " '21221673',\n",
       " '97526674',\n",
       " '62762136',\n",
       " '48649951',\n",
       " '2877671']"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sample"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [],
   "source": [
    "had = hadobj.loc[:, ['OBJECTID','OBJECTGUID']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 256541 entries, 0 to 256540\n",
      "Data columns (total 2 columns):\n",
      " #   Column      Non-Null Count   Dtype \n",
      "---  ------      --------------   ----- \n",
      " 0   OBJECTID    256541 non-null  object\n",
      " 1   OBJECTGUID  256541 non-null  object\n",
      "dtypes: object(2)\n",
      "memory usage: 3.9+ MB\n"
     ]
    }
   ],
   "source": [
    "had.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 242280 entries, 0 to 242279\n",
      "Data columns (total 17 columns):\n",
      " #   Column    Non-Null Count   Dtype \n",
      "---  ------    --------------   ----- \n",
      " 0   chain     242280 non-null  object\n",
      " 1   levchain  242280 non-null  object\n",
      " 2   10        242280 non-null  object\n",
      " 3   9         242280 non-null  object\n",
      " 4   8         242280 non-null  object\n",
      " 5   7         242280 non-null  object\n",
      " 6   6         242280 non-null  object\n",
      " 7   5         242280 non-null  object\n",
      " 8   4         242280 non-null  object\n",
      " 9   3         242280 non-null  object\n",
      " 10  2         242280 non-null  object\n",
      " 11  1         242280 non-null  object\n",
      " 12  street    242280 non-null  object\n",
      " 13  town      242280 non-null  object\n",
      " 14  leftover  242280 non-null  object\n",
      " 15  muni      242280 non-null  object\n",
      " 16  region    242280 non-null  object\n",
      "dtypes: object(17)\n",
      "memory usage: 31.4+ MB\n"
     ]
    }
   ],
   "source": [
    "dfch.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [],
   "source": [
    "dfch2 = dfch.copy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [],
   "source": [
    "had[['OBJECTID']] = had[['OBJECTID']].astype(float)\n",
    "dfch2[['10', '9', '8', '7', '6', '5', '4', '3', '2', '1']] = dfch2[['10', '9', '8', '7', '6', '5', '4', '3', '2', '1']].astype(float)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 132,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>OBJECTID</th>\n",
       "      <th>OBJECTGUID</th>\n",
       "      <th>chain</th>\n",
       "      <th>levchain</th>\n",
       "      <th>10</th>\n",
       "      <th>9</th>\n",
       "      <th>8</th>\n",
       "      <th>7</th>\n",
       "      <th>6</th>\n",
       "      <th>5</th>\n",
       "      <th>4</th>\n",
       "      <th>3</th>\n",
       "      <th>2</th>\n",
       "      <th>1</th>\n",
       "      <th>street</th>\n",
       "      <th>town</th>\n",
       "      <th>leftover</th>\n",
       "      <th>muni</th>\n",
       "      <th>region</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>45196673.0</td>\n",
       "      <td>2bbf97d1-af74-4f19-bc66-cdf43835cb0e</td>\n",
       "      <td>(45196673, 447147, 444817, 95239113, 95239112,...</td>\n",
       "      <td>(10, 8, 6, 4, 3, 1)</td>\n",
       "      <td>45196673.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>447147.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>444817.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>95239113.0</td>\n",
       "      <td>95239112.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>442495.0</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>[4]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>20364220.0</td>\n",
       "      <td>2c8b132e-2094-4870-88c2-6e644735548a</td>\n",
       "      <td>(20364220, 448191, 157721129, 442495)</td>\n",
       "      <td>(10, 6, 3, 1)</td>\n",
       "      <td>20364220.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>448191.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>157721129.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>442495.0</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>14033232.0</td>\n",
       "      <td>2d4c885c-cdf0-4945-8951-cc3df80fbcb0</td>\n",
       "      <td>(14033232, 445941, 442679, 95239122, 95239121,...</td>\n",
       "      <td>(10, 8, 5, 4, 3, 1)</td>\n",
       "      <td>14033232.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>445941.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>442679.0</td>\n",
       "      <td>95239122.0</td>\n",
       "      <td>95239121.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>442495.0</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "      <td>[4]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>21564216.0</td>\n",
       "      <td>2e77a52a-2ee8-4441-a756-2e8773a52a94</td>\n",
       "      <td>(21564216, 442978, 442636, 95239183, 442495)</td>\n",
       "      <td>(10, 8, 5, 3, 1)</td>\n",
       "      <td>21564216.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>442978.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>442636.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>95239183.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>442495.0</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>54221186.0</td>\n",
       "      <td>2f359b37-8822-46b8-a400-7c51d0453345</td>\n",
       "      <td>(54221186, 456239, 157721103, 442495)</td>\n",
       "      <td>(10, 6, 3, 1)</td>\n",
       "      <td>54221186.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>456239.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>157721103.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>442495.0</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     OBJECTID                            OBJECTGUID  \\\n",
       "0  45196673.0  2bbf97d1-af74-4f19-bc66-cdf43835cb0e   \n",
       "1  20364220.0  2c8b132e-2094-4870-88c2-6e644735548a   \n",
       "2  14033232.0  2d4c885c-cdf0-4945-8951-cc3df80fbcb0   \n",
       "3  21564216.0  2e77a52a-2ee8-4441-a756-2e8773a52a94   \n",
       "4  54221186.0  2f359b37-8822-46b8-a400-7c51d0453345   \n",
       "\n",
       "                                               chain             levchain  \\\n",
       "0  (45196673, 447147, 444817, 95239113, 95239112,...  (10, 8, 6, 4, 3, 1)   \n",
       "1              (20364220, 448191, 157721129, 442495)        (10, 6, 3, 1)   \n",
       "2  (14033232, 445941, 442679, 95239122, 95239121,...  (10, 8, 5, 4, 3, 1)   \n",
       "3       (21564216, 442978, 442636, 95239183, 442495)     (10, 8, 5, 3, 1)   \n",
       "4              (54221186, 456239, 157721103, 442495)        (10, 6, 3, 1)   \n",
       "\n",
       "           10   9         8   7         6         5           4            3  \\\n",
       "0  45196673.0 NaN  447147.0 NaN  444817.0       NaN  95239113.0   95239112.0   \n",
       "1  20364220.0 NaN       NaN NaN  448191.0       NaN         NaN  157721129.0   \n",
       "2  14033232.0 NaN  445941.0 NaN       NaN  442679.0  95239122.0   95239121.0   \n",
       "3  21564216.0 NaN  442978.0 NaN       NaN  442636.0         NaN   95239183.0   \n",
       "4  54221186.0 NaN       NaN NaN  456239.0       NaN         NaN  157721103.0   \n",
       "\n",
       "    2         1 street town leftover muni  \\\n",
       "0 NaN  442495.0      8    6      [4]  [3]   \n",
       "1 NaN  442495.0      6    1       []  [3]   \n",
       "2 NaN  442495.0      8    5      [4]  [3]   \n",
       "3 NaN  442495.0      8    5       []  [3]   \n",
       "4 NaN  442495.0      6    1       []  [3]   \n",
       "\n",
       "                                    region  \n",
       "0  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "1  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "2  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "3  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "4  C:/Users/GlazkovOI/minzdrav/data/gar\\29  "
      ]
     },
     "execution_count": 132,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_merged = pd.merge(had, dfch2, left_on='OBJECTID', right_on=['10'], how='inner')\n",
    "df_merged.head()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 133,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 242280 entries, 0 to 242279\n",
      "Data columns (total 19 columns):\n",
      " #   Column      Non-Null Count   Dtype  \n",
      "---  ------      --------------   -----  \n",
      " 0   OBJECTID    242280 non-null  float64\n",
      " 1   OBJECTGUID  242280 non-null  object \n",
      " 2   chain       242280 non-null  object \n",
      " 3   levchain    242280 non-null  object \n",
      " 4   10          242280 non-null  float64\n",
      " 5   9           0 non-null       float64\n",
      " 6   8           157247 non-null  float64\n",
      " 7   7           12793 non-null   float64\n",
      " 8   6           178035 non-null  float64\n",
      " 9   5           55889 non-null   float64\n",
      " 10  4           52147 non-null   float64\n",
      " 11  3           242280 non-null  float64\n",
      " 12  2           0 non-null       float64\n",
      " 13  1           242280 non-null  float64\n",
      " 14  street      242280 non-null  object \n",
      " 15  town        242280 non-null  object \n",
      " 16  leftover    242280 non-null  object \n",
      " 17  muni        242280 non-null  object \n",
      " 18  region      242280 non-null  object \n",
      "dtypes: float64(11), object(8)\n",
      "memory usage: 35.1+ MB\n"
     ]
    }
   ],
   "source": [
    "df_merged.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 131,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>OBJECTID</th>\n",
       "      <th>OBJECTGUID</th>\n",
       "      <th>chain</th>\n",
       "      <th>levchain</th>\n",
       "      <th>10</th>\n",
       "      <th>9</th>\n",
       "      <th>8</th>\n",
       "      <th>7</th>\n",
       "      <th>6</th>\n",
       "      <th>5</th>\n",
       "      <th>4</th>\n",
       "      <th>3</th>\n",
       "      <th>2</th>\n",
       "      <th>1</th>\n",
       "      <th>street</th>\n",
       "      <th>town</th>\n",
       "      <th>leftover</th>\n",
       "      <th>muni</th>\n",
       "      <th>region</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>256536</th>\n",
       "      <td>161914397.0</td>\n",
       "      <td>5fb19f56-1e9b-41ae-9e61-a82d15a9d17c</td>\n",
       "      <td>(161914397, 161457797, 442221, 442571, 9523902...</td>\n",
       "      <td>(10, 8, 7, 5, 3, 1)</td>\n",
       "      <td>161914397.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>161457797.0</td>\n",
       "      <td>442221.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>442571.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>95239028.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>442495.0</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "      <td>[7]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>256537</th>\n",
       "      <td>161976116.0</td>\n",
       "      <td>3d41ef95-0cac-4910-a188-6acd0de08a3e</td>\n",
       "      <td>(161976116, 446273, 162033520, 442495)</td>\n",
       "      <td>(10, 7, 3, 1)</td>\n",
       "      <td>161976116.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>446273.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>162033520.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>442495.0</td>\n",
       "      <td>7</td>\n",
       "      <td>1</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>256538</th>\n",
       "      <td>161989761.0</td>\n",
       "      <td>5fbe3892-9b6e-42a3-a24f-3915d989269a</td>\n",
       "      <td>(161989761, 446273, 162033520, 442495)</td>\n",
       "      <td>(10, 7, 3, 1)</td>\n",
       "      <td>161989761.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>446273.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>162033520.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>442495.0</td>\n",
       "      <td>7</td>\n",
       "      <td>1</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>256539</th>\n",
       "      <td>162608197.0</td>\n",
       "      <td>fed1c206-af27-4537-a442-0cfece18a98b</td>\n",
       "      <td>(162608197, 444343, 446185, 95239082, 442495)</td>\n",
       "      <td>(10, 8, 6, 3, 1)</td>\n",
       "      <td>162608197.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>444343.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>446185.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>95239082.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>442495.0</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>256540</th>\n",
       "      <td>162713529.0</td>\n",
       "      <td>0de5a095-9cb2-456e-b999-9f7bf44d6763</td>\n",
       "      <td>(162713529, 162077847, 442521, 95239029, 442495)</td>\n",
       "      <td>(10, 8, 5, 3, 1)</td>\n",
       "      <td>162713529.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>162077847.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>442521.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>95239029.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>442495.0</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           OBJECTID                            OBJECTGUID  \\\n",
       "256536  161914397.0  5fb19f56-1e9b-41ae-9e61-a82d15a9d17c   \n",
       "256537  161976116.0  3d41ef95-0cac-4910-a188-6acd0de08a3e   \n",
       "256538  161989761.0  5fbe3892-9b6e-42a3-a24f-3915d989269a   \n",
       "256539  162608197.0  fed1c206-af27-4537-a442-0cfece18a98b   \n",
       "256540  162713529.0  0de5a095-9cb2-456e-b999-9f7bf44d6763   \n",
       "\n",
       "                                                    chain  \\\n",
       "256536  (161914397, 161457797, 442221, 442571, 9523902...   \n",
       "256537             (161976116, 446273, 162033520, 442495)   \n",
       "256538             (161989761, 446273, 162033520, 442495)   \n",
       "256539      (162608197, 444343, 446185, 95239082, 442495)   \n",
       "256540   (162713529, 162077847, 442521, 95239029, 442495)   \n",
       "\n",
       "                   levchain           10   9            8         7         6  \\\n",
       "256536  (10, 8, 7, 5, 3, 1)  161914397.0 NaN  161457797.0  442221.0       NaN   \n",
       "256537        (10, 7, 3, 1)  161976116.0 NaN          NaN  446273.0       NaN   \n",
       "256538        (10, 7, 3, 1)  161989761.0 NaN          NaN  446273.0       NaN   \n",
       "256539     (10, 8, 6, 3, 1)  162608197.0 NaN     444343.0       NaN  446185.0   \n",
       "256540     (10, 8, 5, 3, 1)  162713529.0 NaN  162077847.0       NaN       NaN   \n",
       "\n",
       "               5   4            3   2         1 street town leftover muni  \\\n",
       "256536  442571.0 NaN   95239028.0 NaN  442495.0      8    5      [7]  [3]   \n",
       "256537       NaN NaN  162033520.0 NaN  442495.0      7    1       []  [3]   \n",
       "256538       NaN NaN  162033520.0 NaN  442495.0      7    1       []  [3]   \n",
       "256539       NaN NaN   95239082.0 NaN  442495.0      8    6       []  [3]   \n",
       "256540  442521.0 NaN   95239029.0 NaN  442495.0      8    5       []  [3]   \n",
       "\n",
       "                                         region  \n",
       "256536  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "256537  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "256538  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "256539  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "256540  C:/Users/GlazkovOI/minzdrav/data/gar\\29  "
      ]
     },
     "execution_count": 131,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_merged.tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 128,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>OBJECTID</th>\n",
       "      <th>OBJECTGUID</th>\n",
       "      <th>chain</th>\n",
       "      <th>levchain</th>\n",
       "      <th>10</th>\n",
       "      <th>9</th>\n",
       "      <th>8</th>\n",
       "      <th>7</th>\n",
       "      <th>6</th>\n",
       "      <th>5</th>\n",
       "      <th>4</th>\n",
       "      <th>3</th>\n",
       "      <th>2</th>\n",
       "      <th>1</th>\n",
       "      <th>street</th>\n",
       "      <th>town</th>\n",
       "      <th>leftover</th>\n",
       "      <th>muni</th>\n",
       "      <th>region</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>445407.0</td>\n",
       "      <td>425d519f-3636-41bd-ae7e-0c284911ada9</td>\n",
       "      <td>(33238432, 447128, 444817, 95239113, 95239112,...</td>\n",
       "      <td>(10, 8, 6, 4, 3, 1)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>425d519f-3636-41bd-ae7e-0c284911ada9</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>[4]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>95239078.0</td>\n",
       "      <td>6621d717-388a-4533-9571-142c34a22acc</td>\n",
       "      <td>(81986147, 455404, 454228, 157924581, 442495)</td>\n",
       "      <td>(10, 8, 6, 3, 1)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>6621d717-388a-4533-9571-142c34a22acc</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>95239091.0</td>\n",
       "      <td>42b314b1-95a4-406d-89bd-d81fc316f69c</td>\n",
       "      <td>(20160323, 441258, 442636, 95239183, 442495)</td>\n",
       "      <td>(10, 8, 5, 3, 1)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>42b314b1-95a4-406d-89bd-d81fc316f69c</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>95239119.0</td>\n",
       "      <td>9e0cb420-4511-48a0-bac1-966f6170bfc7</td>\n",
       "      <td>(17648737, 447454, 95239030, 442495)</td>\n",
       "      <td>(10, 6, 3, 1)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9e0cb420-4511-48a0-bac1-966f6170bfc7</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>95239186.0</td>\n",
       "      <td>413ad5f9-fb3d-431e-8619-0376df3e9f4b</td>\n",
       "      <td>(19761418, 450371, 449406, 95239146, 95239143,...</td>\n",
       "      <td>(10, 8, 6, 4, 3, 1)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>413ad5f9-fb3d-431e-8619-0376df3e9f4b</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>[4]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     OBJECTID                            OBJECTGUID  \\\n",
       "0    445407.0  425d519f-3636-41bd-ae7e-0c284911ada9   \n",
       "1  95239078.0  6621d717-388a-4533-9571-142c34a22acc   \n",
       "2  95239091.0  42b314b1-95a4-406d-89bd-d81fc316f69c   \n",
       "3  95239119.0  9e0cb420-4511-48a0-bac1-966f6170bfc7   \n",
       "4  95239186.0  413ad5f9-fb3d-431e-8619-0376df3e9f4b   \n",
       "\n",
       "                                               chain             levchain  \\\n",
       "0  (33238432, 447128, 444817, 95239113, 95239112,...  (10, 8, 6, 4, 3, 1)   \n",
       "1      (81986147, 455404, 454228, 157924581, 442495)     (10, 8, 6, 3, 1)   \n",
       "2       (20160323, 441258, 442636, 95239183, 442495)     (10, 8, 5, 3, 1)   \n",
       "3               (17648737, 447454, 95239030, 442495)        (10, 6, 3, 1)   \n",
       "4  (19761418, 450371, 449406, 95239146, 95239143,...  (10, 8, 6, 4, 3, 1)   \n",
       "\n",
       "    10   9    8                                     7    6    5  \\\n",
       "0  NaN NaN  NaN  425d519f-3636-41bd-ae7e-0c284911ada9  NaN  NaN   \n",
       "1  NaN NaN  NaN                                   NaN  NaN  NaN   \n",
       "2  NaN NaN  NaN                                   NaN  NaN  NaN   \n",
       "3  NaN NaN  NaN                                   NaN  NaN  NaN   \n",
       "4  NaN NaN  NaN                                   NaN  NaN  NaN   \n",
       "\n",
       "                                      4                                     3  \\\n",
       "0                                   NaN                                   NaN   \n",
       "1  6621d717-388a-4533-9571-142c34a22acc                                   NaN   \n",
       "2  42b314b1-95a4-406d-89bd-d81fc316f69c                                   NaN   \n",
       "3  9e0cb420-4511-48a0-bac1-966f6170bfc7                                   NaN   \n",
       "4                                   NaN  413ad5f9-fb3d-431e-8619-0376df3e9f4b   \n",
       "\n",
       "    2    1 street town leftover muni                                   region  \n",
       "0 NaN  NaN      8    6      [4]  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "1 NaN  NaN      8    6       []  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "2 NaN  NaN      8    5       []  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "3 NaN  NaN      6    1       []  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "4 NaN  NaN      8    6      [4]  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  "
      ]
     },
     "execution_count": 128,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Создаем новый DataFrame для результата\n",
    "df_result = pd.concat([had, dfch2], axis=1)\n",
    "\n",
    "# Проходимся по всем столбцам второго DataFrame\n",
    "for column in dfch2.columns:\n",
    "    # Если столбец содержит только 'nan', пропускаем его\n",
    "    if dfch2[column].isna().all():\n",
    "        continue\n",
    "    \n",
    "    # Ищем совпадения 'OBJECTID' из первого DataFrame во втором\n",
    "    matches = had.loc[had['OBJECTID'].isin(dfch2[column].dropna())]\n",
    "    \n",
    "    # Если совпадений нет, пропускаем этот столбец\n",
    "    if matches.empty:\n",
    "        continue\n",
    "    \n",
    "    # Создаем новый столбец в df_result и заполняем его 'OBJECTGUID' из matches\n",
    "    # new_column_name = f'{column}_OBJECTGUID'\n",
    "    df_result[new_column_name] = matches['OBJECTGUID']\n",
    "\n",
    "df_result.head()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 118,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 256541 entries, 0 to 256540\n",
      "Data columns (total 27 columns):\n",
      " #   Column         Non-Null Count   Dtype  \n",
      "---  ------         --------------   -----  \n",
      " 0   OBJECTID       256541 non-null  float64\n",
      " 1   OBJECTGUID     256541 non-null  object \n",
      " 2   chain          242280 non-null  object \n",
      " 3   levchain       242280 non-null  object \n",
      " 4   10             242280 non-null  float64\n",
      " 5   9              0 non-null       float64\n",
      " 6   8              157247 non-null  float64\n",
      " 7   7              12793 non-null   float64\n",
      " 8   6              178035 non-null  float64\n",
      " 9   5              55889 non-null   float64\n",
      " 10  4              52147 non-null   float64\n",
      " 11  3              242280 non-null  float64\n",
      " 12  2              0 non-null       float64\n",
      " 13  1              242280 non-null  float64\n",
      " 14  street         242280 non-null  object \n",
      " 15  town           242280 non-null  object \n",
      " 16  leftover       242280 non-null  object \n",
      " 17  muni           242280 non-null  object \n",
      " 18  region         242280 non-null  object \n",
      " 19  10_OBJECTGUID  242280 non-null  object \n",
      " 20  8_OBJECTGUID   7450 non-null    object \n",
      " 21  7_OBJECTGUID   476 non-null     object \n",
      " 22  6_OBJECTGUID   3729 non-null    object \n",
      " 23  5_OBJECTGUID   13 non-null      object \n",
      " 24  4_OBJECTGUID   93 non-null      object \n",
      " 25  3_OBJECTGUID   34 non-null      object \n",
      " 26  1_OBJECTGUID   1 non-null       object \n",
      "dtypes: float64(11), object(16)\n",
      "memory usage: 52.8+ MB\n"
     ]
    }
   ],
   "source": [
    "df_result.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 134,
   "metadata": {},
   "outputs": [],
   "source": [
    "for x in range(1, 11, 1):\n",
    "    df_merged[f'{x}'] = df_merged[f'{x}'].astype(str).apply(lambda y: y.split('.')[0] if y == y else y)\n",
    "    df_merged[f'{x}'] = df_merged[f'{x}'].apply(lambda y: y if y != '' else np.nan)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 135,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 256541 entries, 0 to 256540\n",
      "Data columns (total 19 columns):\n",
      " #   Column      Non-Null Count   Dtype  \n",
      "---  ------      --------------   -----  \n",
      " 0   OBJECTID    256541 non-null  float64\n",
      " 1   OBJECTGUID  256541 non-null  object \n",
      " 2   chain       242280 non-null  object \n",
      " 3   levchain    242280 non-null  object \n",
      " 4   10          242280 non-null  object \n",
      " 5   9           0 non-null       float64\n",
      " 6   8           7450 non-null    object \n",
      " 7   7           476 non-null     object \n",
      " 8   6           3729 non-null    object \n",
      " 9   5           13 non-null      object \n",
      " 10  4           93 non-null      object \n",
      " 11  3           34 non-null      object \n",
      " 12  2           0 non-null       float64\n",
      " 13  1           1 non-null       object \n",
      " 14  street      242280 non-null  object \n",
      " 15  town        242280 non-null  object \n",
      " 16  leftover    242280 non-null  object \n",
      " 17  muni        242280 non-null  object \n",
      " 18  region      242280 non-null  object \n",
      "dtypes: float64(3), object(16)\n",
      "memory usage: 37.2+ MB\n"
     ]
    }
   ],
   "source": [
    "df_result.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 142,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_struct_addr(x):\n",
    "# названия населенных пунктов\n",
    "    if x['town'] != 'nan' and x[x['town']] in hadobjd:\n",
    "        town = hadobjd[x[x['town']]]\n",
    "        town_type= town['TYPELONGNAME']\n",
    "        town_name = town['NAME']\n",
    "    else:\n",
    "        town_type = ''\n",
    "        town_name = ''\n",
    "\n",
    "# названия улиц\n",
    "    if x['street'] != 'nan' and x[x['street']] in hadobjd:\n",
    "        street = hadobjd[x[x['street']]]\n",
    "        street_type = street['TYPELONGNAME']\n",
    "        street_name = street['NAME']\n",
    "    else:\n",
    "        street_type = ''\n",
    "        street_name = ''\n",
    "\n",
    "# нумерация домов\n",
    "    house = hadobjd[x['10']]\n",
    "    tpln = house['TYPELONGNAME'] + ' ' if house['TYPELONGNAME'] == house['TYPELONGNAME'] else ''\n",
    "    tpln1 = house['TYPELONGNAME1'] + ' ' if house['TYPELONGNAME1'] == house['TYPELONGNAME1'] else ''\n",
    "    tpln2 = house['TYPELONGNAME2'] + ' ' if house['TYPELONGNAME2'] == house['TYPELONGNAME2'] else ''\n",
    "    guid = house['OBJECTGUID']\n",
    "    house0 = tpln + house['HOUSENUM']\n",
    "    house1 = ''\n",
    "    house2 = ''\n",
    "\n",
    "    if house['HOUSENUM1'] == house['HOUSENUM1']:\n",
    "        house1 = tpln1 + house['HOUSENUM1']\n",
    "    if house['HOUSENUM2'] == house['HOUSENUM2']:\n",
    "        house2 = tpln2 + house['HOUSENUM2']\n",
    "\n",
    "# дополнительное территориальное деление\n",
    "    leftover1 = []\n",
    "    leftover2 = []\n",
    "    for y in x['leftover']:\n",
    "        leftover1.append(hadobjd[x[y]]['TYPELONGNAME'])\n",
    "        leftover2.append(hadobjd[x[y]]['NAME'])\n",
    "    leftover1 = ' '.join(leftover1)\n",
    "    leftover2 = ' '.join(leftover2)\n",
    "\n",
    "# деление по муниципальным районам, округам\n",
    "    municip1 = []\n",
    "    municip2 = []\n",
    "    for y in x['muni']:\n",
    "        municip1.append(hadobjd[x[y]]['TYPELONGNAME'])\n",
    "        municip2.append(hadobjd[x[y]]['NAME'])\n",
    "    municip1 = ' '.join(municip1)\n",
    "    municip2 = ' '.join(municip2)\n",
    "\n",
    "\n",
    "    return {\n",
    "        'guid': guid,\n",
    "        'town_type': town_type,\n",
    "        'town_name': town_name,\n",
    "        'street_type': street_type,\n",
    "        'street_name': street_name,\n",
    "        'house': house0,\n",
    "        'house1': house1,\n",
    "        'house2': house2,\n",
    "        'leftover1': leftover1,\n",
    "        'leftover2': leftover2,\n",
    "        'municip1': municip1,\n",
    "        'municip2': municip2,\n",
    "    }"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 137,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>OBJECTID</th>\n",
       "      <th>OBJECTGUID</th>\n",
       "      <th>chain</th>\n",
       "      <th>levchain</th>\n",
       "      <th>10</th>\n",
       "      <th>9</th>\n",
       "      <th>8</th>\n",
       "      <th>7</th>\n",
       "      <th>6</th>\n",
       "      <th>5</th>\n",
       "      <th>4</th>\n",
       "      <th>3</th>\n",
       "      <th>2</th>\n",
       "      <th>1</th>\n",
       "      <th>street</th>\n",
       "      <th>town</th>\n",
       "      <th>leftover</th>\n",
       "      <th>muni</th>\n",
       "      <th>region</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>45196673.0</td>\n",
       "      <td>2bbf97d1-af74-4f19-bc66-cdf43835cb0e</td>\n",
       "      <td>(45196673, 447147, 444817, 95239113, 95239112,...</td>\n",
       "      <td>(10, 8, 6, 4, 3, 1)</td>\n",
       "      <td>45196673</td>\n",
       "      <td>nan</td>\n",
       "      <td>447147</td>\n",
       "      <td>nan</td>\n",
       "      <td>444817</td>\n",
       "      <td>nan</td>\n",
       "      <td>95239113</td>\n",
       "      <td>95239112</td>\n",
       "      <td>nan</td>\n",
       "      <td>442495</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>[4]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>20364220.0</td>\n",
       "      <td>2c8b132e-2094-4870-88c2-6e644735548a</td>\n",
       "      <td>(20364220, 448191, 157721129, 442495)</td>\n",
       "      <td>(10, 6, 3, 1)</td>\n",
       "      <td>20364220</td>\n",
       "      <td>nan</td>\n",
       "      <td>nan</td>\n",
       "      <td>nan</td>\n",
       "      <td>448191</td>\n",
       "      <td>nan</td>\n",
       "      <td>nan</td>\n",
       "      <td>157721129</td>\n",
       "      <td>nan</td>\n",
       "      <td>442495</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>14033232.0</td>\n",
       "      <td>2d4c885c-cdf0-4945-8951-cc3df80fbcb0</td>\n",
       "      <td>(14033232, 445941, 442679, 95239122, 95239121,...</td>\n",
       "      <td>(10, 8, 5, 4, 3, 1)</td>\n",
       "      <td>14033232</td>\n",
       "      <td>nan</td>\n",
       "      <td>445941</td>\n",
       "      <td>nan</td>\n",
       "      <td>nan</td>\n",
       "      <td>442679</td>\n",
       "      <td>95239122</td>\n",
       "      <td>95239121</td>\n",
       "      <td>nan</td>\n",
       "      <td>442495</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "      <td>[4]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>21564216.0</td>\n",
       "      <td>2e77a52a-2ee8-4441-a756-2e8773a52a94</td>\n",
       "      <td>(21564216, 442978, 442636, 95239183, 442495)</td>\n",
       "      <td>(10, 8, 5, 3, 1)</td>\n",
       "      <td>21564216</td>\n",
       "      <td>nan</td>\n",
       "      <td>442978</td>\n",
       "      <td>nan</td>\n",
       "      <td>nan</td>\n",
       "      <td>442636</td>\n",
       "      <td>nan</td>\n",
       "      <td>95239183</td>\n",
       "      <td>nan</td>\n",
       "      <td>442495</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>54221186.0</td>\n",
       "      <td>2f359b37-8822-46b8-a400-7c51d0453345</td>\n",
       "      <td>(54221186, 456239, 157721103, 442495)</td>\n",
       "      <td>(10, 6, 3, 1)</td>\n",
       "      <td>54221186</td>\n",
       "      <td>nan</td>\n",
       "      <td>nan</td>\n",
       "      <td>nan</td>\n",
       "      <td>456239</td>\n",
       "      <td>nan</td>\n",
       "      <td>nan</td>\n",
       "      <td>157721103</td>\n",
       "      <td>nan</td>\n",
       "      <td>442495</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     OBJECTID                            OBJECTGUID  \\\n",
       "0  45196673.0  2bbf97d1-af74-4f19-bc66-cdf43835cb0e   \n",
       "1  20364220.0  2c8b132e-2094-4870-88c2-6e644735548a   \n",
       "2  14033232.0  2d4c885c-cdf0-4945-8951-cc3df80fbcb0   \n",
       "3  21564216.0  2e77a52a-2ee8-4441-a756-2e8773a52a94   \n",
       "4  54221186.0  2f359b37-8822-46b8-a400-7c51d0453345   \n",
       "\n",
       "                                               chain             levchain  \\\n",
       "0  (45196673, 447147, 444817, 95239113, 95239112,...  (10, 8, 6, 4, 3, 1)   \n",
       "1              (20364220, 448191, 157721129, 442495)        (10, 6, 3, 1)   \n",
       "2  (14033232, 445941, 442679, 95239122, 95239121,...  (10, 8, 5, 4, 3, 1)   \n",
       "3       (21564216, 442978, 442636, 95239183, 442495)     (10, 8, 5, 3, 1)   \n",
       "4              (54221186, 456239, 157721103, 442495)        (10, 6, 3, 1)   \n",
       "\n",
       "         10    9       8    7       6       5         4          3    2  \\\n",
       "0  45196673  nan  447147  nan  444817     nan  95239113   95239112  nan   \n",
       "1  20364220  nan     nan  nan  448191     nan       nan  157721129  nan   \n",
       "2  14033232  nan  445941  nan     nan  442679  95239122   95239121  nan   \n",
       "3  21564216  nan  442978  nan     nan  442636       nan   95239183  nan   \n",
       "4  54221186  nan     nan  nan  456239     nan       nan  157721103  nan   \n",
       "\n",
       "        1 street town leftover muni                                   region  \n",
       "0  442495      8    6      [4]  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "1  442495      6    1       []  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "2  442495      8    5      [4]  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "3  442495      8    5       []  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "4  442495      6    1       []  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  "
      ]
     },
     "execution_count": 137,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_merged.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 165,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>chain</th>\n",
       "      <th>levchain</th>\n",
       "      <th>10</th>\n",
       "      <th>9</th>\n",
       "      <th>8</th>\n",
       "      <th>7</th>\n",
       "      <th>6</th>\n",
       "      <th>5</th>\n",
       "      <th>4</th>\n",
       "      <th>3</th>\n",
       "      <th>2</th>\n",
       "      <th>1</th>\n",
       "      <th>street</th>\n",
       "      <th>town</th>\n",
       "      <th>leftover</th>\n",
       "      <th>muni</th>\n",
       "      <th>region</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>(77146753, 450532, 448573, 157721083, 442495)</td>\n",
       "      <td>(10, 8, 5, 3, 1)</td>\n",
       "      <td>77146753</td>\n",
       "      <td>nan</td>\n",
       "      <td>450532</td>\n",
       "      <td>nan</td>\n",
       "      <td>nan</td>\n",
       "      <td>448573</td>\n",
       "      <td>nan</td>\n",
       "      <td>157721083</td>\n",
       "      <td>nan</td>\n",
       "      <td>442495</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>(77940472, 443840, 445124, 162033520, 442495)</td>\n",
       "      <td>(10, 8, 7, 3, 1)</td>\n",
       "      <td>77940472</td>\n",
       "      <td>nan</td>\n",
       "      <td>443840</td>\n",
       "      <td>445124</td>\n",
       "      <td>nan</td>\n",
       "      <td>nan</td>\n",
       "      <td>nan</td>\n",
       "      <td>162033520</td>\n",
       "      <td>nan</td>\n",
       "      <td>442495</td>\n",
       "      <td>8</td>\n",
       "      <td>7</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>(16172321, 452812, 451486, 162030634, 442495)</td>\n",
       "      <td>(10, 8, 6, 3, 1)</td>\n",
       "      <td>16172321</td>\n",
       "      <td>nan</td>\n",
       "      <td>452812</td>\n",
       "      <td>nan</td>\n",
       "      <td>451486</td>\n",
       "      <td>nan</td>\n",
       "      <td>nan</td>\n",
       "      <td>162030634</td>\n",
       "      <td>nan</td>\n",
       "      <td>442495</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>(35524685, 447670, 162031408, 442495)</td>\n",
       "      <td>(10, 6, 3, 1)</td>\n",
       "      <td>35524685</td>\n",
       "      <td>nan</td>\n",
       "      <td>nan</td>\n",
       "      <td>nan</td>\n",
       "      <td>447670</td>\n",
       "      <td>nan</td>\n",
       "      <td>nan</td>\n",
       "      <td>162031408</td>\n",
       "      <td>nan</td>\n",
       "      <td>442495</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>(41371850, 440099, 442540, 95239186, 442495)</td>\n",
       "      <td>(10, 8, 5, 3, 1)</td>\n",
       "      <td>41371850</td>\n",
       "      <td>nan</td>\n",
       "      <td>440099</td>\n",
       "      <td>nan</td>\n",
       "      <td>nan</td>\n",
       "      <td>442540</td>\n",
       "      <td>nan</td>\n",
       "      <td>95239186</td>\n",
       "      <td>nan</td>\n",
       "      <td>442495</td>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "      <td>[]</td>\n",
       "      <td>[3]</td>\n",
       "      <td>C:/Users/GlazkovOI/minzdrav/data/gar\\29</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                           chain          levchain        10  \\\n",
       "0  (77146753, 450532, 448573, 157721083, 442495)  (10, 8, 5, 3, 1)  77146753   \n",
       "1  (77940472, 443840, 445124, 162033520, 442495)  (10, 8, 7, 3, 1)  77940472   \n",
       "2  (16172321, 452812, 451486, 162030634, 442495)  (10, 8, 6, 3, 1)  16172321   \n",
       "3          (35524685, 447670, 162031408, 442495)     (10, 6, 3, 1)  35524685   \n",
       "4   (41371850, 440099, 442540, 95239186, 442495)  (10, 8, 5, 3, 1)  41371850   \n",
       "\n",
       "     9       8       7       6       5    4          3    2       1 street  \\\n",
       "0  nan  450532     nan     nan  448573  nan  157721083  nan  442495      8   \n",
       "1  nan  443840  445124     nan     nan  nan  162033520  nan  442495      8   \n",
       "2  nan  452812     nan  451486     nan  nan  162030634  nan  442495      8   \n",
       "3  nan     nan     nan  447670     nan  nan  162031408  nan  442495      6   \n",
       "4  nan  440099     nan     nan  442540  nan   95239186  nan  442495      8   \n",
       "\n",
       "  town leftover muni                                   region  \n",
       "0    5       []  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "1    7       []  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "2    6       []  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "3    1       []  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  \n",
       "4    5       []  [3]  C:/Users/GlazkovOI/minzdrav/data/gar\\29  "
      ]
     },
     "execution_count": 165,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfch.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 166,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 242280 entries, 0 to 242279\n",
      "Data columns (total 17 columns):\n",
      " #   Column    Non-Null Count   Dtype \n",
      "---  ------    --------------   ----- \n",
      " 0   chain     242280 non-null  object\n",
      " 1   levchain  242280 non-null  object\n",
      " 2   10        242280 non-null  object\n",
      " 3   9         242280 non-null  object\n",
      " 4   8         242280 non-null  object\n",
      " 5   7         242280 non-null  object\n",
      " 6   6         242280 non-null  object\n",
      " 7   5         242280 non-null  object\n",
      " 8   4         242280 non-null  object\n",
      " 9   3         242280 non-null  object\n",
      " 10  2         242280 non-null  object\n",
      " 11  1         242280 non-null  object\n",
      " 12  street    242280 non-null  object\n",
      " 13  town      242280 non-null  object\n",
      " 14  leftover  242280 non-null  object\n",
      " 15  muni      242280 non-null  object\n",
      " 16  region    242280 non-null  object\n",
      "dtypes: object(17)\n",
      "memory usage: 31.4+ MB\n"
     ]
    }
   ],
   "source": [
    "dfch.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 143,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'guid': '2bbf97d1-af74-4f19-bc66-cdf43835cb0e',\n",
       " 'town_type': 'Рабочий поселок',\n",
       " 'town_name': 'Коноша',\n",
       " 'street_type': 'Улица',\n",
       " 'street_name': 'Мамонова',\n",
       " 'house': 'Дом 39',\n",
       " 'house1': '',\n",
       " 'house2': '',\n",
       " 'leftover1': 'городское поселение',\n",
       " 'leftover2': 'Коношское',\n",
       " 'municip1': 'Муниципальный район',\n",
       " 'municip2': 'Коношский'}"
      ]
     },
     "execution_count": 143,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "struct_addresses = df_merged.apply(get_struct_addr, axis=1)\n",
    "struct_addresses[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 144,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>guid</th>\n",
       "      <th>town_type</th>\n",
       "      <th>town_name</th>\n",
       "      <th>street_type</th>\n",
       "      <th>street_name</th>\n",
       "      <th>house</th>\n",
       "      <th>house1</th>\n",
       "      <th>house2</th>\n",
       "      <th>leftover1</th>\n",
       "      <th>leftover2</th>\n",
       "      <th>municip1</th>\n",
       "      <th>municip2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>160947</th>\n",
       "      <td>958ded7f-ec5e-4a45-bd8f-47c6b640b9d6</td>\n",
       "      <td>Город</td>\n",
       "      <td>Новодвинск</td>\n",
       "      <td>Улица</td>\n",
       "      <td>Ворошилова</td>\n",
       "      <td>Здание 26</td>\n",
       "      <td>Строение 160</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Городской округ</td>\n",
       "      <td>город Новодвинск</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>126681</th>\n",
       "      <td>3fb84eec-8018-4af4-b261-08d48bf98cb2</td>\n",
       "      <td>городское поселение</td>\n",
       "      <td>Кулойское</td>\n",
       "      <td>Поселок</td>\n",
       "      <td>Кулойского совхоза</td>\n",
       "      <td>Дом 2</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Муниципальный район</td>\n",
       "      <td>Вельский</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>241293</th>\n",
       "      <td>23d9cde3-8181-4da9-8546-d943bad0966f</td>\n",
       "      <td>Область</td>\n",
       "      <td>Архангельская</td>\n",
       "      <td>Деревня</td>\n",
       "      <td>Рикасиха</td>\n",
       "      <td>Здание 63а</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Муниципальный округ</td>\n",
       "      <td>Приморский</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150140</th>\n",
       "      <td>c0f91c84-740b-497e-ac7f-2a3ee795160f</td>\n",
       "      <td>Город</td>\n",
       "      <td>Онега</td>\n",
       "      <td>Улица</td>\n",
       "      <td>Школьная</td>\n",
       "      <td>Дом 31</td>\n",
       "      <td>Корпус 61</td>\n",
       "      <td></td>\n",
       "      <td>городское поселение</td>\n",
       "      <td>Онежское</td>\n",
       "      <td>Муниципальный район</td>\n",
       "      <td>Онежский</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>237151</th>\n",
       "      <td>33bfdb61-706b-42a4-a93a-80be13961cf6</td>\n",
       "      <td>Город</td>\n",
       "      <td>Няндома</td>\n",
       "      <td>Улица</td>\n",
       "      <td>Ленина</td>\n",
       "      <td>Дом 13</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Муниципальный округ</td>\n",
       "      <td>Няндомский</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>158140</th>\n",
       "      <td>4140e5b8-55be-4a13-930c-ae5a42ed9c64</td>\n",
       "      <td>Город</td>\n",
       "      <td>Мирный</td>\n",
       "      <td>Ряд(ы)</td>\n",
       "      <td>26-й</td>\n",
       "      <td>Здание 5</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Территория</td>\n",
       "      <td>гаражная зона Плесцы</td>\n",
       "      <td>Городской округ</td>\n",
       "      <td>Мирный</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>60380</th>\n",
       "      <td>c957dd38-07fe-41bc-9c3c-f086cbc9226c</td>\n",
       "      <td>Область</td>\n",
       "      <td>Архангельская</td>\n",
       "      <td>Деревня</td>\n",
       "      <td>Красная Гора</td>\n",
       "      <td>Дом 3</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Муниципальный округ</td>\n",
       "      <td>Котласский</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47950</th>\n",
       "      <td>12be2c0a-1d79-4f40-b969-ef1c77019dc6</td>\n",
       "      <td>Рабочий поселок</td>\n",
       "      <td>Приводино</td>\n",
       "      <td>Улица</td>\n",
       "      <td>Рощинская</td>\n",
       "      <td>Дом 20</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Муниципальный округ</td>\n",
       "      <td>Котласский</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>142308</th>\n",
       "      <td>37ba65b9-7b5f-4011-8d1d-e8860c89f0c9</td>\n",
       "      <td>Город</td>\n",
       "      <td>Каргополь</td>\n",
       "      <td>Улица</td>\n",
       "      <td>Ошевенская</td>\n",
       "      <td>Дом 50</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Муниципальный округ</td>\n",
       "      <td>Каргопольский</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>82332</th>\n",
       "      <td>ee8671db-8570-413e-a7a7-3668aad73f57</td>\n",
       "      <td>Город</td>\n",
       "      <td>Котлас</td>\n",
       "      <td>Улица</td>\n",
       "      <td>Первомайская</td>\n",
       "      <td>Дом 3</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Городской округ</td>\n",
       "      <td>Котлас</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                        guid            town_type  \\\n",
       "160947  958ded7f-ec5e-4a45-bd8f-47c6b640b9d6                Город   \n",
       "126681  3fb84eec-8018-4af4-b261-08d48bf98cb2  городское поселение   \n",
       "241293  23d9cde3-8181-4da9-8546-d943bad0966f              Область   \n",
       "150140  c0f91c84-740b-497e-ac7f-2a3ee795160f                Город   \n",
       "237151  33bfdb61-706b-42a4-a93a-80be13961cf6                Город   \n",
       "158140  4140e5b8-55be-4a13-930c-ae5a42ed9c64                Город   \n",
       "60380   c957dd38-07fe-41bc-9c3c-f086cbc9226c              Область   \n",
       "47950   12be2c0a-1d79-4f40-b969-ef1c77019dc6      Рабочий поселок   \n",
       "142308  37ba65b9-7b5f-4011-8d1d-e8860c89f0c9                Город   \n",
       "82332   ee8671db-8570-413e-a7a7-3668aad73f57                Город   \n",
       "\n",
       "            town_name street_type         street_name       house  \\\n",
       "160947     Новодвинск       Улица          Ворошилова   Здание 26   \n",
       "126681      Кулойское     Поселок  Кулойского совхоза       Дом 2   \n",
       "241293  Архангельская     Деревня            Рикасиха  Здание 63а   \n",
       "150140          Онега       Улица            Школьная      Дом 31   \n",
       "237151        Няндома       Улица              Ленина      Дом 13   \n",
       "158140         Мирный      Ряд(ы)                26-й    Здание 5   \n",
       "60380   Архангельская     Деревня        Красная Гора       Дом 3   \n",
       "47950       Приводино       Улица           Рощинская      Дом 20   \n",
       "142308      Каргополь       Улица          Ошевенская      Дом 50   \n",
       "82332          Котлас       Улица        Первомайская       Дом 3   \n",
       "\n",
       "              house1 house2            leftover1             leftover2  \\\n",
       "160947  Строение 160                                                     \n",
       "126681                                                                   \n",
       "241293                                                                   \n",
       "150140     Корпус 61         городское поселение              Онежское   \n",
       "237151                                                                   \n",
       "158140                                Территория  гаражная зона Плесцы   \n",
       "60380                                                                    \n",
       "47950                                                                    \n",
       "142308                                                                   \n",
       "82332                                                                    \n",
       "\n",
       "                   municip1          municip2  \n",
       "160947      Городской округ  город Новодвинск  \n",
       "126681  Муниципальный район          Вельский  \n",
       "241293  Муниципальный округ        Приморский  \n",
       "150140  Муниципальный район          Онежский  \n",
       "237151  Муниципальный округ        Няндомский  \n",
       "158140      Городской округ            Мирный  \n",
       "60380   Муниципальный округ        Котласский  \n",
       "47950   Муниципальный округ        Котласский  \n",
       "142308  Муниципальный округ     Каргопольский  \n",
       "82332       Городской округ            Котлас  "
      ]
     },
     "execution_count": 144,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "structdf = pd.DataFrame.from_records(struct_addresses)\n",
    "structdf.sample(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 145,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>guid</th>\n",
       "      <th>town_type</th>\n",
       "      <th>town_name</th>\n",
       "      <th>street_type</th>\n",
       "      <th>street_name</th>\n",
       "      <th>house</th>\n",
       "      <th>house1</th>\n",
       "      <th>house2</th>\n",
       "      <th>leftover1</th>\n",
       "      <th>leftover2</th>\n",
       "      <th>municip1</th>\n",
       "      <th>municip2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>228580</th>\n",
       "      <td>1844a078-d27c-488e-bf7d-d0124045394a</td>\n",
       "      <td>Область</td>\n",
       "      <td>Архангельская</td>\n",
       "      <td>Территория садоводческого некоммерческого това...</td>\n",
       "      <td>Клюковка</td>\n",
       "      <td>Дом 34</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Муниципальный округ</td>\n",
       "      <td>Приморский</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>220719</th>\n",
       "      <td>0b1c58ee-3c3f-4000-a816-05a763921f71</td>\n",
       "      <td>Город</td>\n",
       "      <td>Онега</td>\n",
       "      <td>Улица</td>\n",
       "      <td>Приречная</td>\n",
       "      <td>Дом 59</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>городское поселение</td>\n",
       "      <td>Онежское</td>\n",
       "      <td>Муниципальный район</td>\n",
       "      <td>Онежский</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20105</th>\n",
       "      <td>9ab5e570-175c-426d-b4a2-25d87b699288</td>\n",
       "      <td>Поселок</td>\n",
       "      <td>Ерцево</td>\n",
       "      <td>Улица</td>\n",
       "      <td>Комсомольская</td>\n",
       "      <td>Дом 9а</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>сельское поселение</td>\n",
       "      <td>Ерцевское</td>\n",
       "      <td>Муниципальный район</td>\n",
       "      <td>Коношский</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>153571</th>\n",
       "      <td>f12691a1-6374-4892-8b63-9007974fbd8a</td>\n",
       "      <td>Поселок</td>\n",
       "      <td>Ломовое</td>\n",
       "      <td>Улица</td>\n",
       "      <td>Профсоюзная</td>\n",
       "      <td>Дом 18</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Муниципальный округ</td>\n",
       "      <td>Плесецкий</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>184661</th>\n",
       "      <td>e2876a5b-fd2e-4413-bcc5-a429e92e09d4</td>\n",
       "      <td>Область</td>\n",
       "      <td>Архангельская</td>\n",
       "      <td>Село</td>\n",
       "      <td>Койда</td>\n",
       "      <td>Дом 46</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Муниципальный округ</td>\n",
       "      <td>Мезенский</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>183201</th>\n",
       "      <td>b2c36590-e42c-4551-923a-f0d07a450dde</td>\n",
       "      <td>Город</td>\n",
       "      <td>Новодвинск</td>\n",
       "      <td>Улица</td>\n",
       "      <td>Ворошилова</td>\n",
       "      <td>Дом 3</td>\n",
       "      <td>Строение 1</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Городской округ</td>\n",
       "      <td>город Новодвинск</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>191726</th>\n",
       "      <td>50fa74f3-5ad3-4d31-865f-8c93b7ea8fcd</td>\n",
       "      <td>Поселок</td>\n",
       "      <td>Погост</td>\n",
       "      <td>Улица</td>\n",
       "      <td>Центральная</td>\n",
       "      <td>Дом 22</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>сельское поселение</td>\n",
       "      <td>Судромское</td>\n",
       "      <td>Муниципальный район</td>\n",
       "      <td>Вельский</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>183898</th>\n",
       "      <td>26f2d219-3111-4ce5-bcb2-28010a6ccdf6</td>\n",
       "      <td>Город</td>\n",
       "      <td>Новодвинск</td>\n",
       "      <td>Улица</td>\n",
       "      <td>Солнечная</td>\n",
       "      <td>Здание 20</td>\n",
       "      <td>Строение 302</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Городской округ</td>\n",
       "      <td>город Новодвинск</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>80299</th>\n",
       "      <td>3d6423e6-3507-4528-8a17-4ccab6201ace</td>\n",
       "      <td>Город</td>\n",
       "      <td>Котлас</td>\n",
       "      <td>Улица</td>\n",
       "      <td>Красносельская</td>\n",
       "      <td>Дом 50</td>\n",
       "      <td>Корпус 1</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Городской округ</td>\n",
       "      <td>Котлас</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>83409</th>\n",
       "      <td>702c0337-3925-47b4-b827-b1109c27f029</td>\n",
       "      <td>сельское поселение</td>\n",
       "      <td>Емецкое</td>\n",
       "      <td>Деревня</td>\n",
       "      <td>Кулига</td>\n",
       "      <td>Дом 1</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Муниципальный район</td>\n",
       "      <td>Холмогорский</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                        guid           town_type  \\\n",
       "228580  1844a078-d27c-488e-bf7d-d0124045394a             Область   \n",
       "220719  0b1c58ee-3c3f-4000-a816-05a763921f71               Город   \n",
       "20105   9ab5e570-175c-426d-b4a2-25d87b699288             Поселок   \n",
       "153571  f12691a1-6374-4892-8b63-9007974fbd8a             Поселок   \n",
       "184661  e2876a5b-fd2e-4413-bcc5-a429e92e09d4             Область   \n",
       "183201  b2c36590-e42c-4551-923a-f0d07a450dde               Город   \n",
       "191726  50fa74f3-5ad3-4d31-865f-8c93b7ea8fcd             Поселок   \n",
       "183898  26f2d219-3111-4ce5-bcb2-28010a6ccdf6               Город   \n",
       "80299   3d6423e6-3507-4528-8a17-4ccab6201ace               Город   \n",
       "83409   702c0337-3925-47b4-b827-b1109c27f029  сельское поселение   \n",
       "\n",
       "            town_name                                        street_type  \\\n",
       "228580  Архангельская  Территория садоводческого некоммерческого това...   \n",
       "220719          Онега                                              Улица   \n",
       "20105          Ерцево                                              Улица   \n",
       "153571        Ломовое                                              Улица   \n",
       "184661  Архангельская                                               Село   \n",
       "183201     Новодвинск                                              Улица   \n",
       "191726         Погост                                              Улица   \n",
       "183898     Новодвинск                                              Улица   \n",
       "80299          Котлас                                              Улица   \n",
       "83409         Емецкое                                            Деревня   \n",
       "\n",
       "           street_name      house        house1 house2            leftover1  \\\n",
       "228580        Клюковка     Дом 34                                             \n",
       "220719       Приречная     Дом 59                       городское поселение   \n",
       "20105    Комсомольская     Дом 9а                        сельское поселение   \n",
       "153571     Профсоюзная     Дом 18                                             \n",
       "184661           Койда     Дом 46                                             \n",
       "183201      Ворошилова      Дом 3    Строение 1                               \n",
       "191726     Центральная     Дом 22                        сельское поселение   \n",
       "183898       Солнечная  Здание 20  Строение 302                               \n",
       "80299   Красносельская     Дом 50      Корпус 1                               \n",
       "83409           Кулига      Дом 1                                             \n",
       "\n",
       "         leftover2             municip1          municip2  \n",
       "228580              Муниципальный округ        Приморский  \n",
       "220719    Онежское  Муниципальный район          Онежский  \n",
       "20105    Ерцевское  Муниципальный район         Коношский  \n",
       "153571              Муниципальный округ         Плесецкий  \n",
       "184661              Муниципальный округ         Мезенский  \n",
       "183201                  Городской округ  город Новодвинск  \n",
       "191726  Судромское  Муниципальный район          Вельский  \n",
       "183898                  Городской округ  город Новодвинск  \n",
       "80299                   Городской округ            Котлас  \n",
       "83409               Муниципальный район      Холмогорский  "
      ]
     },
     "execution_count": 145,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "structdf.sample(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 147,
   "metadata": {},
   "outputs": [],
   "source": [
    "structdf.to_csv('C:/Users/GlazkovOI/minzdrav/data/29_addr_for_Excel_with_guid.csv', sep=';', index=False, encoding='cp1251')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 146,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 242280 entries, 0 to 242279\n",
      "Data columns (total 12 columns):\n",
      " #   Column       Non-Null Count   Dtype \n",
      "---  ------       --------------   ----- \n",
      " 0   guid         242280 non-null  object\n",
      " 1   town_type    242280 non-null  object\n",
      " 2   town_name    242280 non-null  object\n",
      " 3   street_type  242280 non-null  object\n",
      " 4   street_name  242280 non-null  object\n",
      " 5   house        242280 non-null  object\n",
      " 6   house1       242280 non-null  object\n",
      " 7   house2       242280 non-null  object\n",
      " 8   leftover1    242280 non-null  object\n",
      " 9   leftover2    242280 non-null  object\n",
      " 10  municip1     242280 non-null  object\n",
      " 11  municip2     242280 non-null  object\n",
      "dtypes: object(12)\n",
      "memory usage: 22.2+ MB\n"
     ]
    }
   ],
   "source": [
    "structdf.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Запись в БД"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 149,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "  0%|          | 0/242280 [53:30<?, ?it/s]\n",
      "  0%|          | 0/256541 [52:33<?, ?it/s]\n",
      "  0%|          | 0/256541 [45:35<?, ?it/s]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "280"
      ]
     },
     "execution_count": 149,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import sqlalchemy\n",
    "from sqlalchemy import create_engine\n",
    "\n",
    "from dbconfig import MZ_DWH # подключение к базе данных\n",
    "\n",
    "host, port, user, password, database = MZ_DWH()\n",
    "\n",
    "engine = sqlalchemy.create_engine(f\"postgresql+psycopg2://{user}:{password}@{host}:{port}/{database}\")\n",
    "\n",
    "structdf.to_sql('29_addr_guid', engine, if_exists='replace', index=False, schema='db0')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>town_type</th>\n",
       "      <th>street_type</th>\n",
       "      <th>leftover1</th>\n",
       "      <th>leftover2</th>\n",
       "      <th>municip1</th>\n",
       "      <th>municip2</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>town_name</th>\n",
       "      <th>street_name</th>\n",
       "      <th>house</th>\n",
       "      <th>house1</th>\n",
       "      <th>house2</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">Абакумово</th>\n",
       "      <th>Молодежная</th>\n",
       "      <th>Дом 1</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <td>[Деревня]</td>\n",
       "      <td>[Улица]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[Муниципальный округ]</td>\n",
       "      <td>[Каргопольский]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"4\" valign=\"top\">Онежская</th>\n",
       "      <th>Дом 1</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <td>[Деревня]</td>\n",
       "      <td>[Улица]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[Муниципальный округ]</td>\n",
       "      <td>[Каргопольский]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Дом 2</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <td>[Деревня]</td>\n",
       "      <td>[Улица]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[Муниципальный округ]</td>\n",
       "      <td>[Каргопольский]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Дом 3</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <td>[Деревня]</td>\n",
       "      <td>[Улица]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[Муниципальный округ]</td>\n",
       "      <td>[Каргопольский]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Дом 4</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <td>[Деревня]</td>\n",
       "      <td>[Улица]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[Муниципальный округ]</td>\n",
       "      <td>[Каргопольский]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                           town_type street_type leftover1  \\\n",
       "town_name street_name house house1 house2                                    \n",
       "Абакумово Молодежная  Дом 1                [Деревня]     [Улица]        []   \n",
       "          Онежская    Дом 1                [Деревня]     [Улица]        []   \n",
       "                      Дом 2                [Деревня]     [Улица]        []   \n",
       "                      Дом 3                [Деревня]     [Улица]        []   \n",
       "                      Дом 4                [Деревня]     [Улица]        []   \n",
       "\n",
       "                                          leftover2               municip1  \\\n",
       "town_name street_name house house1 house2                                    \n",
       "Абакумово Молодежная  Дом 1                      []  [Муниципальный округ]   \n",
       "          Онежская    Дом 1                      []  [Муниципальный округ]   \n",
       "                      Дом 2                      []  [Муниципальный округ]   \n",
       "                      Дом 3                      []  [Муниципальный округ]   \n",
       "                      Дом 4                      []  [Муниципальный округ]   \n",
       "\n",
       "                                                  municip2  \n",
       "town_name street_name house house1 house2                   \n",
       "Абакумово Молодежная  Дом 1                [Каргопольский]  \n",
       "          Онежская    Дом 1                [Каргопольский]  \n",
       "                      Дом 2                [Каргопольский]  \n",
       "                      Дом 3                [Каргопольский]  \n",
       "                      Дом 4                [Каргопольский]  "
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped = structdf.groupby(by=['town_name', 'street_name', 'house', 'house1', 'house2']).aggregate(lambda x: x.to_list())\n",
    "grouped.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>leftover</th>\n",
       "      <th>muni</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>town</th>\n",
       "      <th>street</th>\n",
       "      <th>house</th>\n",
       "      <th>house1</th>\n",
       "      <th>house2</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"4\" valign=\"top\">Область Архангельская</th>\n",
       "      <th>Деревня Бутырская</th>\n",
       "      <th>Дом 6</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <td>[, ]</td>\n",
       "      <td>[Муниципальный округ Приморский, Муниципальный...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Деревня Аверкиевская</th>\n",
       "      <th>Дом 6</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <td>[, ]</td>\n",
       "      <td>[Муниципальный округ Красноборский, Муниципаль...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Деревня Васильевская</th>\n",
       "      <th>Дом 23</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <td>[, ]</td>\n",
       "      <td>[Муниципальный округ Верхнетоемский, Муниципал...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Деревня Киселевская</th>\n",
       "      <th>Дом 5</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <td>[, ]</td>\n",
       "      <td>[Муниципальный округ Шенкурский, Муниципальный...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Поселок Красный Бор</th>\n",
       "      <th>Улица Центральная</th>\n",
       "      <th>Дом 14</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <td>[, ]</td>\n",
       "      <td>[Муниципальный округ Пинежский, Муниципальный ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">Область Архангельская</th>\n",
       "      <th>Деревня Низ</th>\n",
       "      <th>Дом 3</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <td>[, , ]</td>\n",
       "      <td>[Муниципальный округ Плесецкий, Муниципальный ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Деревня Заручей</th>\n",
       "      <th>Дом 47</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <td>[, ]</td>\n",
       "      <td>[Муниципальный округ Приморский, Муниципальный...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Деревня Якушевская</th>\n",
       "      <th>Дом 4</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <td>[, ]</td>\n",
       "      <td>[Муниципальный округ Устьянский, Муниципальный...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Деревня Андроновская</th>\n",
       "      <th>Дом 4</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <td>[, ]</td>\n",
       "      <td>[Муниципальный округ Каргопольский, Муниципаль...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Деревня Гришинская</th>\n",
       "      <th>Дом 21</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <td>[, ]</td>\n",
       "      <td>[Муниципальный округ Вилегодский, Муниципальны...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                                leftover  \\\n",
       "town                  street               house  house1 house2            \n",
       "Область Архангельская Деревня Бутырская    Дом 6                    [, ]   \n",
       "                      Деревня Аверкиевская Дом 6                    [, ]   \n",
       "                      Деревня Васильевская Дом 23                   [, ]   \n",
       "                      Деревня Киселевская  Дом 5                    [, ]   \n",
       "Поселок Красный Бор   Улица Центральная    Дом 14                   [, ]   \n",
       "Область Архангельская Деревня Низ          Дом 3                  [, , ]   \n",
       "                      Деревня Заручей      Дом 47                   [, ]   \n",
       "                      Деревня Якушевская   Дом 4                    [, ]   \n",
       "                      Деревня Андроновская Дом 4                    [, ]   \n",
       "                      Деревня Гришинская   Дом 21                   [, ]   \n",
       "\n",
       "                                                                                                              muni  \n",
       "town                  street               house  house1 house2                                                     \n",
       "Область Архангельская Деревня Бутырская    Дом 6                 [Муниципальный округ Приморский, Муниципальный...  \n",
       "                      Деревня Аверкиевская Дом 6                 [Муниципальный округ Красноборский, Муниципаль...  \n",
       "                      Деревня Васильевская Дом 23                [Муниципальный округ Верхнетоемский, Муниципал...  \n",
       "                      Деревня Киселевская  Дом 5                 [Муниципальный округ Шенкурский, Муниципальный...  \n",
       "Поселок Красный Бор   Улица Центральная    Дом 14                [Муниципальный округ Пинежский, Муниципальный ...  \n",
       "Область Архангельская Деревня Низ          Дом 3                 [Муниципальный округ Плесецкий, Муниципальный ...  \n",
       "                      Деревня Заручей      Дом 47                [Муниципальный округ Приморский, Муниципальный...  \n",
       "                      Деревня Якушевская   Дом 4                 [Муниципальный округ Устьянский, Муниципальный...  \n",
       "                      Деревня Андроновская Дом 4                 [Муниципальный округ Каргопольский, Муниципаль...  \n",
       "                      Деревня Гришинская   Дом 21                [Муниципальный округ Вилегодский, Муниципальны...  "
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped[(grouped['muni'].apply(lambda x: len(x) > 1))].sample(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# structdf.to_csv('C:/Users/GlazkovOI/minzdrav/data/29_struct_addresses.csv', sep=';', index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>region_name</th>\n",
       "      <th>municipality</th>\n",
       "      <th>settelment</th>\n",
       "      <th>type</th>\n",
       "      <th>latitude</th>\n",
       "      <th>longitude</th>\n",
       "      <th>map_number</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Архангельская область</td>\n",
       "      <td>Населённые пункты, не относящиеся к районам</td>\n",
       "      <td>Архангельск</td>\n",
       "      <td>город обл.подч.</td>\n",
       "      <td>64°32.5'</td>\n",
       "      <td>40°33.5'</td>\n",
       "      <td>Q-37-130</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Архангельская область</td>\n",
       "      <td>Населённые пункты, не относящиеся к районам</td>\n",
       "      <td>Коряжма</td>\n",
       "      <td>город обл.подч.</td>\n",
       "      <td>61°18.7'</td>\n",
       "      <td>47°10.3'</td>\n",
       "      <td>P-38-107</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Архангельская область</td>\n",
       "      <td>Населённые пункты, не относящиеся к районам</td>\n",
       "      <td>Котлас</td>\n",
       "      <td>город обл.подч.</td>\n",
       "      <td>61°15'</td>\n",
       "      <td>46°38.6'</td>\n",
       "      <td>P-38-106</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Архангельская область</td>\n",
       "      <td>Населённые пункты, не относящиеся к районам</td>\n",
       "      <td>Новодвинск</td>\n",
       "      <td>город обл.подч.</td>\n",
       "      <td>64°24.8'</td>\n",
       "      <td>40°49.1'</td>\n",
       "      <td>Q-37-130</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Архангельская область</td>\n",
       "      <td>Населённые пункты, не относящиеся к районам</td>\n",
       "      <td>Онега</td>\n",
       "      <td>город обл.подч.</td>\n",
       "      <td>63°54.5'</td>\n",
       "      <td>38°06.6'</td>\n",
       "      <td>P-37-005</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             region_name                                 municipality  \\\n",
       "0  Архангельская область  Населённые пункты, не относящиеся к районам   \n",
       "1  Архангельская область  Населённые пункты, не относящиеся к районам   \n",
       "2  Архангельская область  Населённые пункты, не относящиеся к районам   \n",
       "3  Архангельская область  Населённые пункты, не относящиеся к районам   \n",
       "4  Архангельская область  Населённые пункты, не относящиеся к районам   \n",
       "\n",
       "    settelment             type  latitude longitude map_number  \n",
       "0  Архангельск  город обл.подч.  64°32.5'  40°33.5'   Q-37-130  \n",
       "1      Коряжма  город обл.подч.  61°18.7'  47°10.3'   P-38-107  \n",
       "2       Котлас  город обл.подч.    61°15'  46°38.6'   P-38-106  \n",
       "3   Новодвинск  город обл.подч.  64°24.8'  40°49.1'   Q-37-130  \n",
       "4        Онега  город обл.подч.  63°54.5'  38°06.6'   P-37-005  "
      ]
     },
     "execution_count": 273,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arh = pd.read_csv(r'C:/Users/GlazkovOI/Downloads/Telegram Desktop/Архангельская_область.csv', sep=';')\n",
    "arh.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>town_type</th>\n",
       "      <th>town_name</th>\n",
       "      <th>street_type</th>\n",
       "      <th>street_name</th>\n",
       "      <th>house</th>\n",
       "      <th>house1</th>\n",
       "      <th>house2</th>\n",
       "      <th>leftover1</th>\n",
       "      <th>leftover2</th>\n",
       "      <th>municip1</th>\n",
       "      <th>municip2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Территория садоводческого некоммерческого това...</td>\n",
       "      <td>Полёт</td>\n",
       "      <td>Улица</td>\n",
       "      <td>7-я линия</td>\n",
       "      <td>Дом 208</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Муниципальный округ</td>\n",
       "      <td>Приморский</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>сельское поселение</td>\n",
       "      <td>Верхнеустькулойское</td>\n",
       "      <td>Деревня</td>\n",
       "      <td>Лаптевская</td>\n",
       "      <td>Дом 19</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Муниципальный район</td>\n",
       "      <td>Вельский</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>70</th>\n",
       "      <td>Территория садоводческого некоммерческого това...</td>\n",
       "      <td>Волна-1</td>\n",
       "      <td>Улица</td>\n",
       "      <td>Цветочная</td>\n",
       "      <td>Дом 13</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Муниципальный округ</td>\n",
       "      <td>Котласский</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>79</th>\n",
       "      <td>сельское поселение</td>\n",
       "      <td>Чекуевское</td>\n",
       "      <td>Деревня</td>\n",
       "      <td>Поле</td>\n",
       "      <td>Дом 63</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Муниципальный район</td>\n",
       "      <td>Онежский</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>81</th>\n",
       "      <td>сельское поселение</td>\n",
       "      <td>Шеговарское</td>\n",
       "      <td>Деревня</td>\n",
       "      <td>Павловская</td>\n",
       "      <td>Дом 11</td>\n",
       "      <td>Корпус а</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Муниципальный район</td>\n",
       "      <td>Шенкурский</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>242180</th>\n",
       "      <td>сельское поселение</td>\n",
       "      <td>Сойгинское</td>\n",
       "      <td>Деревня</td>\n",
       "      <td>Горка</td>\n",
       "      <td>Дом 20</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Муниципальный район</td>\n",
       "      <td>Ленский</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>242187</th>\n",
       "      <td>сельское поселение</td>\n",
       "      <td>Усть-Вельское</td>\n",
       "      <td>Деревня</td>\n",
       "      <td>Костинская</td>\n",
       "      <td>Дом 20</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Муниципальный район</td>\n",
       "      <td>Вельский</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>242204</th>\n",
       "      <td>сельское поселение</td>\n",
       "      <td>Чекуевское</td>\n",
       "      <td>Деревня</td>\n",
       "      <td>Верховье</td>\n",
       "      <td>Дом 18</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Муниципальный район</td>\n",
       "      <td>Онежский</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>242257</th>\n",
       "      <td>сельское поселение</td>\n",
       "      <td>Сафроновское</td>\n",
       "      <td>Деревня</td>\n",
       "      <td>Микшина Гора</td>\n",
       "      <td>Дом 4</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Муниципальный район</td>\n",
       "      <td>Ленский</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>242278</th>\n",
       "      <td>городское поселение</td>\n",
       "      <td>Коношское</td>\n",
       "      <td>Поселок</td>\n",
       "      <td>Колфонд</td>\n",
       "      <td>Дом 3</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>Муниципальный район</td>\n",
       "      <td>Коношский</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>15474 rows × 11 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                town_type  \\\n",
       "3       Территория садоводческого некоммерческого това...   \n",
       "18                                     сельское поселение   \n",
       "70      Территория садоводческого некоммерческого това...   \n",
       "79                                     сельское поселение   \n",
       "81                                     сельское поселение   \n",
       "...                                                   ...   \n",
       "242180                                 сельское поселение   \n",
       "242187                                 сельское поселение   \n",
       "242204                                 сельское поселение   \n",
       "242257                                 сельское поселение   \n",
       "242278                                городское поселение   \n",
       "\n",
       "                  town_name street_type   street_name    house    house1  \\\n",
       "3                     Полёт       Улица     7-я линия  Дом 208             \n",
       "18      Верхнеустькулойское     Деревня    Лаптевская   Дом 19             \n",
       "70                  Волна-1       Улица     Цветочная   Дом 13             \n",
       "79               Чекуевское     Деревня          Поле   Дом 63             \n",
       "81              Шеговарское     Деревня    Павловская   Дом 11  Корпус а   \n",
       "...                     ...         ...           ...      ...       ...   \n",
       "242180           Сойгинское     Деревня         Горка   Дом 20             \n",
       "242187        Усть-Вельское     Деревня    Костинская   Дом 20             \n",
       "242204           Чекуевское     Деревня      Верховье   Дом 18             \n",
       "242257         Сафроновское     Деревня  Микшина Гора    Дом 4             \n",
       "242278            Коношское     Поселок       Колфонд    Дом 3             \n",
       "\n",
       "       house2 leftover1 leftover2             municip1    municip2  \n",
       "3                                  Муниципальный округ  Приморский  \n",
       "18                                 Муниципальный район    Вельский  \n",
       "70                                 Муниципальный округ  Котласский  \n",
       "79                                 Муниципальный район    Онежский  \n",
       "81                                 Муниципальный район  Шенкурский  \n",
       "...       ...       ...       ...                  ...         ...  \n",
       "242180                             Муниципальный район     Ленский  \n",
       "242187                             Муниципальный район    Вельский  \n",
       "242204                             Муниципальный район    Онежский  \n",
       "242257                             Муниципальный район     Ленский  \n",
       "242278                             Муниципальный район   Коношский  \n",
       "\n",
       "[15474 rows x 11 columns]"
      ]
     },
     "execution_count": 277,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "structdf[~structdf['town_name'].isin(arh['settelment'])]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>region_name</th>\n",
       "      <th>municipality</th>\n",
       "      <th>settelment</th>\n",
       "      <th>type</th>\n",
       "      <th>latitude</th>\n",
       "      <th>longitude</th>\n",
       "      <th>map_number</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Архангельская область</td>\n",
       "      <td>Вельский район</td>\n",
       "      <td>Алексинская</td>\n",
       "      <td>деревня</td>\n",
       "      <td>61°19.3'</td>\n",
       "      <td>41°31.6'</td>\n",
       "      <td>P-37-108</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>Архангельская область</td>\n",
       "      <td>Вельский район</td>\n",
       "      <td>Андрейковская</td>\n",
       "      <td>деревня</td>\n",
       "      <td>61°23'</td>\n",
       "      <td>42°41.7'</td>\n",
       "      <td>P-38-086</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>Архангельская область</td>\n",
       "      <td>Вельский район</td>\n",
       "      <td>Баламутовская</td>\n",
       "      <td>деревня</td>\n",
       "      <td>61°12.2'</td>\n",
       "      <td>41°49.2'</td>\n",
       "      <td>P-37-108</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>Архангельская область</td>\n",
       "      <td>Вельский район</td>\n",
       "      <td>Бегуновская</td>\n",
       "      <td>деревня</td>\n",
       "      <td>61°08'</td>\n",
       "      <td>42°48.2'</td>\n",
       "      <td>P-38-098</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>Архангельская область</td>\n",
       "      <td>Вельский район</td>\n",
       "      <td>Белавинская</td>\n",
       "      <td>деревня</td>\n",
       "      <td>61°32'</td>\n",
       "      <td>42°15.5'</td>\n",
       "      <td>P-38-085</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3945</th>\n",
       "      <td>Архангельская область</td>\n",
       "      <td>город областного подчинения Северодвинск\\n</td>\n",
       "      <td>Палозеро</td>\n",
       "      <td>посёлок</td>\n",
       "      <td>64°08.5'</td>\n",
       "      <td>39°43.1'</td>\n",
       "      <td>Q-37-140</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3954</th>\n",
       "      <td>Архангельская область</td>\n",
       "      <td>город областного подчинения Архангельск</td>\n",
       "      <td>Новый Турдеевск</td>\n",
       "      <td>посёлок</td>\n",
       "      <td>64°27.8'</td>\n",
       "      <td>40°44.9'</td>\n",
       "      <td>Q-37-130</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3958</th>\n",
       "      <td>Архангельская область</td>\n",
       "      <td>город областного подчинения Котлас</td>\n",
       "      <td>Свининская</td>\n",
       "      <td>деревня</td>\n",
       "      <td>61°15.9'</td>\n",
       "      <td>46°50.4'</td>\n",
       "      <td>P-38-106</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3959</th>\n",
       "      <td>Архангельская область</td>\n",
       "      <td>город областного подчинения Котлас</td>\n",
       "      <td>Слуда</td>\n",
       "      <td>деревня</td>\n",
       "      <td>61°15.8'</td>\n",
       "      <td>46°53'</td>\n",
       "      <td>P-38-106</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3960</th>\n",
       "      <td>Архангельская область</td>\n",
       "      <td>город областного подчинения Новодвинск</td>\n",
       "      <td>Павлово</td>\n",
       "      <td>деревня</td>\n",
       "      <td>64°23.3'</td>\n",
       "      <td>40°51.7'</td>\n",
       "      <td>Q-37-130</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2643 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                region_name                                municipality  \\\n",
       "8     Архангельская область                              Вельский район   \n",
       "10    Архангельская область                              Вельский район   \n",
       "15    Архангельская область                              Вельский район   \n",
       "16    Архангельская область                              Вельский район   \n",
       "17    Архангельская область                              Вельский район   \n",
       "...                     ...                                         ...   \n",
       "3945  Архангельская область  город областного подчинения Северодвинск\\n   \n",
       "3954  Архангельская область     город областного подчинения Архангельск   \n",
       "3958  Архангельская область          город областного подчинения Котлас   \n",
       "3959  Архангельская область          город областного подчинения Котлас   \n",
       "3960  Архангельская область      город областного подчинения Новодвинск   \n",
       "\n",
       "           settelment     type  latitude longitude map_number  \n",
       "8         Алексинская  деревня  61°19.3'  41°31.6'   P-37-108  \n",
       "10      Андрейковская  деревня    61°23'  42°41.7'   P-38-086  \n",
       "15      Баламутовская  деревня  61°12.2'  41°49.2'   P-37-108  \n",
       "16        Бегуновская  деревня    61°08'  42°48.2'   P-38-098  \n",
       "17        Белавинская  деревня    61°32'  42°15.5'   P-38-085  \n",
       "...               ...      ...       ...       ...        ...  \n",
       "3945         Палозеро  посёлок  64°08.5'  39°43.1'   Q-37-140  \n",
       "3954  Новый Турдеевск  посёлок  64°27.8'  40°44.9'   Q-37-130  \n",
       "3958       Свининская  деревня  61°15.9'  46°50.4'   P-38-106  \n",
       "3959            Слуда  деревня  61°15.8'    46°53'   P-38-106  \n",
       "3960          Павлово  деревня  64°23.3'  40°51.7'   Q-37-130  \n",
       "\n",
       "[2643 rows x 7 columns]"
      ]
     },
     "execution_count": 279,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arh[~arh['settelment'].isin(structdf['town_name'])]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>town_type</th>\n",
       "      <th>town_name</th>\n",
       "      <th>street_type</th>\n",
       "      <th>street_name</th>\n",
       "      <th>house</th>\n",
       "      <th>house1</th>\n",
       "      <th>house2</th>\n",
       "      <th>leftover1</th>\n",
       "      <th>leftover2</th>\n",
       "      <th>municip1</th>\n",
       "      <th>municip2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [town_type, town_name, street_type, street_name, house, house1, house2, leftover1, leftover2, municip1, municip2]\n",
       "Index: []"
      ]
     },
     "execution_count": 282,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "structdf[structdf['town_name'].isin(['Павлово'])]"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
